Things about GENERATED_BODY()

I’m new to programing UE C++ and I encountered a mistake that confused me: Why VS Intellisense is underlining the GENERATED_BODY macro in red and telling me “this declaration has no storage class or type specifier”? It seems to be related to the line.

I learned from other answers that this is an IntelliSense error, and UE Living Code can indeed be compiled successfully. So I think I can ignore this error, but the error makes my functions “BeginPlay” and “Tick” in CPP getting wrong: “UObject” has no member.
I’m completely confused.

TLDR: IntelliSense error causes GENERATED_BODY macro error. GENERATED_BODY macro error causes CPP file to recognize its parent AActor as UObject, so my VS2022 cannot recognize function BeginPlay and Tick. I need a solution to the error.

1 Like

Intellisense shows a lot of nonsense. You can ignore its errors unless there is a build error.
You should also set the error list to only show build errors, trust me, Intellisense finds a way to show 60.000 non existing errors otherwise:

2 Likes

For context, Unreal Engine uses a ■■■■■ ton of auto-generated code to provide all of its functionality. Macros like UPROPERTY, UCLASS, UENUM etc. doesn’t do anything practical on its own. When you build the Unreal Header Tool parses these macros and creates a corresponding .gen.cpp file with the actual functionality before compiling.

1 Like

This is fixed by using Rider rather than Visual Studio. Rider understands all the Unreal stuff:

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.