You dont need complete defenition for pointers in header (although I dont check auto includes, that are made by UHT)… But I dont know, if Unreal doesnt allow pointer to USTRUCT UProp, but that can be case…
Forward declarations won’t do for USTRUCTs, the UHT needs the complete definition of the struct when you want to use it in a reflected context. So if you declare UPROPERTY() FSubStat* subStats; in RO_AI.h you also need to include RO_Stats.h in the header file (not just the .cpp file). However, you will get another UHT error after that along the lines of ‘cannot have exposed pointer to this type’, because you cannot have a member UPROPERTY-pointer to a USTRUCT.
I kinda solved it, but I am not sure if this is the correct way of solving the problem.
I made a RO_Structure.h - moved every UENUM,USTRUCT to that header
just like this example, and include it to RO_AI.h so that my AI will have the same struct.
but if this is wrong please let me know, for the best solution
yes you do. There is no way to forward declare a USTRUCT. This is not a compiler error but a UHT error, so it is not a C++ issue but a question of what the UHT (Unreal header tool) do and can’t do. They simply haven’t implemented forward declarations for USTRUCTs.
Including header files simply copy-pastes the code of the header file into the location where it is included, so it doesn’t matter whether you move them to a new header file and include that, or simply include the original header file where you had the struct definition before. The point is that the definition of the struct has to be there when you get to the line where you declare the member variable of that type.
As far as forward declaration of ustructs goes: there is no way around including the definition, but it is not really a problem because you cannot have a uproperty pointer to a ustruct anyway. ustructs are meant to be simple containers for data so there should not really be a reason to have member pointers to them and if you have a struct type variable as member (not just a pointer) you need the full definition of the struct anyway because the compiler needs to know the size of the struct to allocate the memory. I get the impression that you think it is a problem that you need to include other header files but it’s really not, we prefer to avoid it when possible because it reduces compilation times but sometimes it is necessary.