How to make USTRUCT with parent object?

Hello.

I want to make USTRUCT, that can have parent object with same type:

USTRUCT(BlueprintType)
struct RETARGETTEST_API FMYJOINT
{
	GENERATED_USTRUCT_BODY()


		UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "LifeSim|GWorld")
		FString name = "";


	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "LifeSim|GWorld")
		bool isRoot = false;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "LifeSim|GWorld")
		TArray<float> offset;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "LifeSim|GWorld")
		TArray<FString> channels;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "LifeSim|GWorld")
	    FMYJOINT parentJoint;

};

The problem is code

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "LifeSim|GWorld")
	    FMYJOINT parentJoint;

It gets error

Error c:\users\\documents\unreal projects\retargettest\source\retargettest\MyStaticMeshActor.h(28)  : error C2460: 'FMYJOINT::parentJoint' : uses 'FMYJOINT', which is being defined
Error C:\Users\\Documents\Unreal Projects\RetargetTest\Source\RetargetTest\MyStaticMeshActor.h(28)  : error C2460: 'FMYJOINT::parentJoint' : uses 'FMYJOINT', which is being defined        c:\users\\documents\unreal projects\retargettest\source\retargettest\MyStaticMeshActor.h(10) : see declaration of 'FMYJOINT'

How to fix this issue?

Thank you!

C++ does not allow you to do this. FMYJOINT is an incomplete type until the closing brace of its declaration.

The normal way around this is to use a pointer to the type instead (that works as a pointer to a type is always the same size, so the compiler knows how to deal with that type), however you can’t have a pointer to a USTRUCT based type in a UPROPERTY, so you might need to make your type a UCLASS instead.

UCLASS(BlueprintType)
class UMYJOINT : public UObject
{
	GENERATED_BODY()

public:
	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "LifeSim|GWorld")
	FString name = "";

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "LifeSim|GWorld")
	bool isRoot = false;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "LifeSim|GWorld")
	TArray<float> offset;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "LifeSim|GWorld")
	TArray<FString> channels;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "LifeSim|GWorld")
	UMYJOINT* parentJoint;
};