The order of the included file

When I was trying to #include “PhysicsEngine/PhysicsHandleComponent.h” file in Grabber.h, between “Components/ActorComponent.h” and “Grabber.generated.h”, the compiler is complaining about the GENERATED_BODY(), saying that the declaration has no storage class or type specifier, and in Grabber.cpp, the Beginplay() and Super::TickComponent(DeltaTime, TickType, ThisTickFunction) are complaining that class “UObject” has no member “BeginPlay” or “TickComponent”.

even though the program will still compile fine, but could someone explain a little more of what’s going on here?

Just don’t bother with it.

Let me cite a UE4 staff member:

You can ignore the red underlines. 
Some of our types and macros are fairly complicated, syntactically, 
and Intellisense doesn't always know how to deal with them.

The GENERATED_BODY is referenced by and references some other UE4 stuff, that expects it to be exactly in THAT line (yes, THAT is unspecific, since the expected line can change) of code. So when you move it down or up, the UE4 stuff is confused and Intellisense throws some errors. If you were to put it back again to its original line, everything is fine again.

As long as it compiles (from inside the UE4 Editor), everything is fine. If it doesn’t, then its most likely YOUR code that’s wrong. Not the UE4 Macros.

Privacy & Terms