Single empty c++ line influences compile result

I have started creating a C++ Environment Query System test.
For testing purposes, I added a struct in “EnvQueryTypes.h” (in the engine folder of the project), then removed it afterwards. The single difference after the deletion of the new struct was a single, empty line (I made sure to use a text diff tool with the original version).
Whenever I had a fresh C++ test in my project, the compiling results in errors. When I didn’t have a C++ EQS test in my project, the scenario of the first screenshot compiles as well.

Screenshot (look at line 452, added empty line) after re-build of the solution

Screenshot (look at line 452, removed the empty line) after re-build of the solution

Sadly I can’t test for reproduction right now, since I would have to re-download the engine, since engine code is shared among projects.

How is it possible that a single empty line affects compiling results?

Hi,

It’s hard to tell from the information you have provided, but at a guess, UnrealHeaderTool hasn’t rerun for some reason. Perhaps if you added and removed the line while UnrealHeaderTool was running, it would get confused with the timestamps of the generated code and not rerun.

But the reason for the errors is that the .generated.h header contains line references to the reflection macros in the .h file. GENERATED_BODY(), for example, can be specified multiple times for different classes/structs in the same header, but the macro needs to expand to the right struct-specific code in each case, and this disambiguation is done by the line number of the macro. So if the .generated.h doesn’t match the .h, it will result in these kind of compile errors.

Hope this is clear,

Steve

So specific lines including line number are taken into account in the generated.h headers, I see, thank you.

But then, how do I rerun the UnrealHeaderTool?

You should just be able to make a trivial change to the header (add a space, delete it, save) then build again, and the build tool should notice that the header is out-of-date and rerun UnrealHeaderTool.

Steve

This doesn’t work. That’s how I’ve reproduced the problem in my file too. If I add a line somewhere, those errors get thrown around. It wasn’t a “one-time-thing”; if I add a line, I get errors. Maybe it’s the generated.h file itself that should be regenerated completely? If so, how do I do that?

When you make the change, do you see UnrealHeaderTool run?

It could also be that your header from a module which you don’t have a dependency on. If the module is not a dependent of your project, then changes to it will be ignored when you build your project.

Steve

Ah, I do not see the UnrealHeaderTool being run after having made the change. That does explain why the generated.h isn’t being updated accordingly. Also, my project does have the dependency necessary for using it included.

It could be that I once by mistake editted the generated.h file; could this be responsible?

It should be enough that the .generated.h file has an older timestamp than the .h file, or doesn’t exist at all. You can try deleting it and building and see it gets built.

If you find and open the .uhtmanifest file for your project+config then it will tell you which headers are being considered for being rebuilt. The file is in compressed JSON format - you should be able to search for the name of your header in any normal text editor, but you might want to use a JSON formatter if you actually want to read it.

Steve