Download

Should I define structs with GENERATED_USTRUCT_BODY or GENERATED_BODY?

This is likely a silly question, but when I create a new struct, the two following versions both compile fine:



USTRUCT()
struct FSomeStruct {
	GENERATED_USTRUCT_BODY()
};

USTRUCT()
struct FSomeOtherStruct {
	GENERATED_BODY()
};

Is there any difference between the two? I’ve always used GENERATED_USTRUCT_BODY(), if only because that’s what was used in Rama’s excellent tutorial, but I have absolutely no idea what either one accomplishes.

Hello HInoue

No, there is absolutely no difference in the new versions, since they’re defined like this:
#define GENERATED_USTRUCT_BODY(…) GENERATED_BODY(…)

That’s useful to know, thank you :slight_smile:

OMG for some reason I thought that GENERATED_BODY is a replacement for GENERATED_CLASS_BODY only! Thanks for revealing this!

I also thought that was the case… so GENERATED_BODY() covers all U-Types? Even Interfaces?

Yeah I believe it does now.
Pretty sure at one point I tried it and found that it wasn’t accepted for interfaces, but it is now so I guess they gradually moved everything over to the one macro.