USTRUCT in namespace - cannot create *.generated.h

Hello,

I created simple struct like this:

    USTRUCT()
    struct FTestStruct
    {
        GENERATED_USTRUCT_BODY()
    };

Everything works fine but when I’ve moved that struct to namespace, VS reports error that it cannot find TestStruct.generated.h (without namespace that file is created properly).

Is it normal behaviour of UHT or am I missing something?

Thanks in advance,
cloud

From what I’ve seen, the tradition is to just use the global namespace. In a way it makes a lot of sense, because USTRUCT and UCLASS objects are all things that are exposed to UE4’s reflection system (and allows them to be editable in Blueprints.) It’d be kind of weird to have those in namespaces due to organizational reasons.

I would say it is normal behavior from UHT, but I might be wrong. All I know is that what you are trying to do isn’t what everyone else does. Do you really need namespaces that badly?

I don’t need namespaces for structs/classes that will be used for blueprints. I’m just moving my codebase from Ogre3D project to UE4 and I have every class that is connected to simulation/AI in my own namespace to avoid name collisions. If it is necessary I will remove blueprintable classes from namespace, that is no problem :D.

Then don’t use USTRUCT/UCLASS if you don’t need to expose those to Blueprints. Or just name them something unique to avoid naming conflicts.

PS: Please comment on my answer instead of posting your own answer in response.

Oh, and the .generated.h is only for UCLASS/USTRUCT objects anyway. If you don’t have those, you don’t get a .generated.h.

Sorry for a new post :smiley:
Of course not every class in my codebase will be USTRUCT/UCLASS as I only need that for classes that will be edited in blueprints (I have separate editor for these from Ogre project, but I will move that to UE).

If my post answers your question, please mark it as the answer so it shows up at the top of this question when people do a search for it.