Struct circular dependency

Hi,

I’m trying to create a c++ struct like so:

USTRUCT(BlueprintType)
struct A{

     B* var;

}

USTRUCT(BlueprintType)
struct B{

         TArray<A> var;
}

but when I try to compile, UE tells me that B is an undeclared type. So I tried to forward declare the structs but it didnt’ work because if I add USTRUCT(BlueprintType), UE tells me that it’s missing an {.

I’ve looked at the other posts and at Rama’s tutorial on the wiki, but couldn’t understand how to do it.

My objective is to create a struct that includes other instances of it inside. However, as I know that UE4 doesn’t support it, I did it like this. Is there any other way? Or is it possible to forward declare correctly a USTRUCT in unreal engine?

Thanks in advance.

Why can’t use forward declaration? This code should compile without problems:

USTRUCT(BlueprintType) struct A{

      struct B* var;
 
 }
 
 USTRUCT(BlueprintType)
 struct B{
 
          TArray<A> var;
 }

Forwarding Structs works, but you cannot use UStructs as pointers like that.
Look here: Forward Declaration for Structure - Programming & Scripting - Unreal Engine Forums

What you can do instead is create a wrapper UObject that contains a UStruct A which can be inserted inside Struct A while containing another instance of Struct A and so on…
Or just do not use Struct at all and just make Struct A be a UObject that chain references instances of itself instead.