Why are there two definitions of UObject?

There appears to be two definitions of UObject. One in:

CoreUObject\Public\UObject\Object.h

and the other in:

CoreUObject\Public\UObject\NoExportTypes.h

The first has no UCLASS macro defined and derives from UObjectBaseUtility, and the other has UCLASS(abstract, noexport) and derives from nothing.

Can anyone explain what is going on? Why are there two different definitions of UObject?

Hi!

As the comment at the top of NoExportTypes.h says these are
Reflection mirrors of C++ structs defined in Core or CoreUObject
noexport basically means that no autogenerated code will be created by the UHT for these classes, they are merely there to generate reflection data for the editor. For example the actual FVector class in Public\Math\Vector.h has X, Y and Z members but they are not uproperties, yet the editor knows about them. This is because of the FVector in NoExportTypes.h which does have these same members marked as uproperties. I guess this is because they don’t want the overhead of the autogenerated code for the most essential low-level classes in the engine but people should still be able to use them in the editor. Same for the UObject class and all the other types in the header.

1 Like