Compiler error after modifying a UCLASS

Sometimes after a comparatively large modification of a UCLASS, I fail to compile the project. The compiler log is really simple. I’ve attached it below. This problem cannot be solved other than revert the whole project. I wonder why is this happening. The only thing that I know is that this error is related to the UCLASS definition. Unreal Header Tool cannot find my class.

1>------ Build started: Project: UE4, Configuration: BuiltWithUnrealBuildTool Win32 ------
2>------ Build started: Project: test_project, Configuration: Development_Editor x64 ------
2>  Creating makefile for test_projectEditor (no existing makefile)
2>  Performing full C++ include scan (no include cache file)
2>  Parsing headers for test_projectEditor
2>    Running UnrealHeaderTool "D:\test_project\test_project.uproject" "D:\test_project 4.15\Intermediate\Build\Win64\test_projectEditor\Development\test_projectEditor.uhtmanifest" -LogCmds="loginit warning, logexit warning, logdatabase error" -Unattended -WarningsAsErrors -installed
2>  D:/test_project 4.15/Source/test_project/Public/test_projectPlayerController.h(13) : LogWindows:Error: === Critical error: ===
2>  D:/test_project 4.15/Source/test_project/Public/test_projectPlayerController.h(13) : LogWindows:Error:
2>  D:/test_project/Source/test_project/Public/test_projectPlayerController.h(13) : LogWindows:Error: Assertion failed: FoundClass [File:D:\Build\++UE4+Release-4.15+Compile\Sync\Engine\Source\Programs\UnrealHeaderTool\Private\HeaderParser.cpp] [Line: 5076]
2>  D:/test_project/Source/test_project/Public/test project.h(13) : LogWindows:Error:
2>  D:/test_project/Source/test_project/Public/test_projectPlayerController.h(13) : LogWindows:Error:
2>  D:/test_project/Source/test_project/Public/test_projectPlayerController.h(13) : LogWindows:Error:
2>  D:/test_project/Source/test_project/Public/test_projectPlayerController.h(13) : LogWindows:Error:
2>EXEC : error : UnrealHeaderTool failed for target 'test_projectEditor' (platform: Win64, module info: D:\test_project 4.15\Intermediate\Build\Win64\test_projectEditor\Development\test_projectEditor.uhtmanifest, exit code: CrashOrAssert (3)).
2>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.MakeFile.Targets(37,5): error MSB3073: The command "D:\Unreal\UE_4.15\Engine\Build\BatchFiles\Build.bat test_projectEditor Win64 Development "D:\test_project 4.15\test_project.uproject" -waitmutex" exited with code 3.
========== Build: 1 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

I found out that deleting the UCLASS() macro can disable the compiler error, but this is not the result I wanted.

I got the following compiler error after commenting the asserted line. It may be helpful.

35>  Building UnrealHeaderTool...
35>  Target is up to date
35>  Deploying UnrealHeaderTool Win64 Development...
35>  Total build time: 0.15 seconds (NoActionsToExecute executor: 0.00 seconds)
35>  Parsing headers for RaynetAB_Test13Editor
35>    Running UnrealHeaderTool "D:\test_project\test_project.uproject" "D:\test_project\Intermediate\Build\Win64\test_projectEditor\Development\test_projectEditor.uhtmanifest" -LogCmds="loginit warning, logexit warning, logdatabase error" -Unattended -WarningsAsErrors
35>  UnrealHeaderTool failed with exit code 0xC0000005 - check that UE4 prerequisites are installed.
35>EXEC : error : UnrealHeaderTool failed for target 'test_projectEditor' (platform: Win64, module info: D:\test_project\Intermediate\Build\Win64\test_projectEditor\Development\test_projectEditor.uhtmanifest, exit code: -1073741819 (-1073741819)).
35>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.MakeFile.Targets(37,5): error MSB3073: The command "D:\UnrealEngine\Engine\Build\BatchFiles\Build.bat test_projectEditor Win64 Development "D:\test_project\test_project.uproject" -waitmutex" exited with code -1073741819.

This is not compiler error, this is UnrealHeaderTool crashing. UHT is a tool that parse UCLASS(), UPROPERTY() etc and generate extra code that register class and it’s elements to reflection system so engine see them exist (since when you compile C++ code all names and such are turn in to anonymous memory addresses, this is why this system exists for). When you remove UCLASS() you simply making UHT not to parse it at all, but UCLASS() and UHT generated code is required by UObject classes (this includes actors) as engine need to see them in order to manage them properly.

Since UHT don’t return specific error here you might hitting a bug here, can you paste how you declere that class that cause the, UCLASS() and first portion of it (but best would be whole class decleration)?

This is a screenshot of my project file, the problem cannot be solved even if I deleted all other c++ classes and comment all code that I have written. these are the only files that I have

138581-qq图片20170521104218.png

and this is The only file that I have modified.

138570-qq图片20170521103304.png

This is my simplified project files, I can replicate the previous assertions through this.
link text

Ok, so this happens only with AGameStateBase? Does this also happens when you have other thigns declered in class?

Also check few other things invidually:

-Remove RAYNETAB_TEST13_API

-Try GENERATED_UCLASS_BODY() insted of GENERATED_BODY() (this will require oyu to make a constructor with const FObjectInitializer& ObjectInitializer argument in cpp file

Hi,

It’s because you have a space between UCLASS and the brackets. I’ll make sure that that is checked for and doesn’t just cause a UHT crash.

Steve

@Steve Robb That is a perfect solution. Thank you all for helping. I have used my original c++ formatting options and did not recognize this.

Hello! I ran into the same problem, but had a different cause.

I did the taboo thing of moving code around in the folder structure. When opening Unreal, it left a reference to the old code file in there, though it didn’t exist.

For anyone like me who is OCD about code file structure :P, make sure you delete your Binaries folder and re-generate your project files to remove that old code reference in Unreal.

After I did that, my code compiles again. Hope this helps someone out!