Hello there,
I am having an issue trying to get some code to compile because of some kind of hangup with the evaluation of the macro at compile-time.
#define GAME_STRUCT(StructName) USTRUCT() struct StructName
And I’m using it this way:
GAME_STRUCT(FMyStruct)
{
GENERATED_BODY()
// ... Stuff goes here
}
When I write something like above, I get this error:
GameDefinitions.h(107): warning : The identifier 'GENERATED_BODY' was detected in a block being skipped. Was this intentional?
But if I use the code:
USTRUCT()
struct FMyStruct
{
GENERATED_BODY()
// ...
}
It works fine.
And it’s leaving my head scratching because, as I understand it, macros are just simple text substitution. Ergo, shouldn’t the Unreal Header Tool pick this up just fine?
Or does UHT run FIRST before the compiler evaluates the macros? I can see that causing issues. If that’s the case, is there a workaround?
What’s especially frustrating is that if I code this:
#define GAME_ENUM(EnumName) UENUM() enum class EnumName : uint8
It compiles just fine!
Why on earth does the latter work for UHT, but not the former? Is there some special syntax I need to add in order to get UHT to recognize this properly?
Thank you.