Developer Notes

Unfortunately we simply don't have the time and resources to make UHT work like a true compiler. UHT can currently parse the most common C++ syntax cases and that works for 95% of cases.

Description

A project building in Visual Studio will sometimes fail with the error Unrecognized type 'FBar' - type must be a UCLASS, USTRUCT or UENUM. This can occur in situations where one struct was referenced by a second struct and both structs were changed so that the first struct now references the second, but only if the include pre-processor instruction includes a space (ie. "# include").

The user who reported the issue suspects that there is a problem with how FHeaderParser::SimplifiedClassParse handles the include instruction. The whitespace after the # seems to be throwing it off.

Steps to Reproduce
  1. Create a new code project using the First Person template.
  2. Build the project in Visual Studio.
  3. Open the project in the Editor.
  4. Add two Actor code classes.
  5. Close the Editor.
  6. In the header file for one class, add the following code:
    USTRUCT()
    struct FFoo {
    	GENERATED_USTRUCT_BODY()
    
    	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Foo")
    	bool bRepro;
    };
    
  7. In the header file for the second class, add the following struct:
    USTRUCT()
    struct FBar {
    	GENERATED_USTRUCT_BODY()
    
    	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Bar")
    	TArray<FFoo> Foos;
    };
    
  8. Add an include for the first header file in the second.
    • Make sure there is no space in the include (eg. "#include").
  9. Build the project.
  10. Once the project builds successfully, comment out the include added in step 8.
  11. Change the UPROPERTY in the second struct to the following:
    UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Bar")
    bool bRepro;
    
  12. Change the UPROPERTY in the first struct to the following:
    UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Foo")
    TArray<FBar> Bars;
    
  13. Add an include for the second header file in the first header file.
    • Make sure again that there is no space.
  14. Build the project.
  15. Change the include line added in step 13 to include a space after the # character (eg. "# include").
  16. Build the project.

RESULT:
The build fails with the error: Unrecognized type 'FBar' - type must be a UCLASS, USTRUCT or UENUM

EXPECTED:
The build succeeds since a space in the include pre-processor instruction should not affect the instruction.

Have Comments or More Details?

Head over to the existingAnswerHub thread and let us know what's up.

0
Login to Vote

Won't Fix
ComponentCore
Affects Versions4.12.54.134.14
Target Fix4.14
CreatedSep 23, 2016
ResolvedSep 29, 2016
UpdatedApr 27, 2018