In my general understanding, you add an include files you want to use stuff from another header. I am currently running into an issue of circular dependency and is using shootergame as an example. How do they get away with adding only Generated file type.
EDIT : CORRECTION, I’m looking at ShooterTypes not ShooterImpactEffect. sorry
I’m looking at ShooterTypes. How do they get away with only
Saying TWeakOBjectPtr must only be used on a UClass.
Since they demanded a UClass. I try doing
class AMyNeededClass : public ACharacter ;
this then come out with error saying "missing ‘,’ before ‘;’ "
I also tried doing
UClass()
Class AMyNeededClass : public ACharacter
I got some other error ( The class name must match the name of the class header file it is contained in (‘PCTypes’), with an appropriate prefix added (A for Actors, U for other classes) )
Right, so TWeakObjectPtr has a default constructor, and a constructor which takes a pointer. Only the latter of those performs the UObject type check, and it will have needed to see the type declaration to be able to do that (a forward declaration will not suffice).
This sounds like an issue with the instantiation of your TWeakObjectPtr rather than your declaration of it.
With regard to your question about how the the forward declaration is happening, you can do a forward declaration inline, so the following does forward declare AMyNeededClass, but only for the scope of that variable declaration (as an aside, I don’t like the inline version of forward declarations since it can cause issues with namespaces, but since UE4 doesn’t really use namespaces, it’s not so much of an issue here).
you are so right about this. I’ve been barking up the wrong tree all this while. It is indeed the instantiation of it.
I actually left the declaration untouched at (my version of ) ShooterTypes.h . Apparently it’s the instantiation at (my verison of ) ShooterImpactEffect that needed to add the Include.