I have the same problem - unfortunately you will have to move your struct to the tracer.h
otherwise it will not work
Normally in C++ you would use forward declaration, but it doesn’t work in this scenario when you are messing with USTRUCTS - onse possible solution is to promote it to UCLASS and then forward declare. Another solution I suppose would be to use TWeakPTR.
You can use forward type declarations here. For example in your header you can write
// #include "Fish.h"
void SomeFunctionEatingFish(class UFish* fresh);
without including files with UFish declarations. This method have limitations - you can declare only pointers or references of unknown classes and can’t use any methods of this class in the file before including a header related to the class. When creating a .cpp file you still have to include all required headers to use your classes.
If it’s not applicable you can move your UStruct declaration to a separate file and include it both from watcher and tracer files.
Hello,
in my Plugin I’ve got a Object which inherits from UObject. It’s name is Watcher. Inside Watcher.h I declared a USTRUCT FMyStruct. The struct consists of some FVectors.
Then I’ve got another Object inherited from UObject called Tracer.
Watcher has a member of type Tracer. I want Tracer to do LineTraces , so i declared a method with Parameter MyStruct.
Inside Watcher.h I included Tracer.h .
Inside Tracer.h I included Watcher.h .
Compiler can’t resolve type of parameter FMyStruct in void Trace(…) .
I’ve tried different includes. None worked for me.
How do I include properly?
#include "Tracer.h"
#include "Watcher.generated.h"
USTRUCT()
struct FMyStruct
{
GENERATED_BODY()
.............................................
};
UCLASS()
class UWatcher : public UObject
{
GENERATED_BODY()
private:
FMyStruct values;
UTracer* tracer;
};
Tracer.h
#include "Watcher.h"
#include "Tracer.generated.h"
UCLASS()
class UTracer : public UObject
{
GENERATED_BODY()
private:
FHitResult Hitresult;
void Trace(FMyStruct values);
.................................................
};
Thanks, type declartion works
Ooops, it’s actually forward type declarations, I skipped that word…