#include (still) breaks Generated_Body()

I want to bump an issue that has been in the engine for years** but that has become especially problematic since the IWYU system got shipped. Basically, you can only add as many #includes as you have blank lines above #include “filename.generated.h”. If you mess with the lines above the UClass statement in any other way, you get an error saying that Generated_Body() ‘has no storage class or class specifier’.

Now, there is a workaround. If you compile in the editor, then refresh the VS project and then reload/reopen the project, the error goes away. Still, it’s annoying to have to jump through this hoop every time you want to include something (not to mention, it’s frustrating and confusing to people who are new to the engine). I believe this issue got marked as solved, but the problem lingers.

**Since 4.8 according to this thread: Adding additional includes breaks my class - Programming & Scripting - Epic Developer Community Forums

I second this. I just tried with 4.18.3 and it still is the same.

I separate a lot of stuff with blank lines in my headers. Includes are one of these things and I never had such issue.

Could you provide some example code that causes it?

As someone who has more experience in Unity, I have to say that Unreal’s C++ doesn’t make things easy in the very least.

I found out that the error is caused by literally moving the GENERATED_BODY() macro to a different line (at least that’s what I’ve noticed) which is mind-boggling to say the least. And the funny thing is that compilation is never consistent with this kind of error. Sometimes it compiles anyway, other times it gives me an error, which is another bundle of weirdness.

My advice is not to move the GENERATED_BODY() to a different line from what it was originally at