I have a project named ProgettoCLParticle and i need to now where is the best place to put includes.
It’s a set of plain classes whit .cpp and .h paired.
I have cyclic dependency.
In each .h there is #pragma once
In general, there should be no need for one UCLASS
-declaring header to include another UCLASS
-declaring header. Since UObject
members in your classes will always be pointers rather than direct values, it’s sufficent to simply put class UMyObject;
above the class holding a UMyObject
reference, or to declare it as UPROPERTY() class UMyObject* MyObject
instead of simply UPROPERTY() UMyObject* MyObject
.
An exception to this is when one UCLASS
subclasses another, but that should only be a one-way include.
If you’re holding USTRUCT
s in your objects, you’ll need to include the header for those. It may be necessary to put the USTRUCT
in its own header to avoid cyclic dependencies.
And .cpp files can include as many headers as they want without giving rise to cyclic inclusions.