Recursive struct do not work

Documentation claims they are supported with forward declaration but it is not the case:

typedef struct
{
    EPropertyType MappingType;
    if (MappingType != 0xFF)
    {
        if (MappingType == EnumProperty)
        {
            Property Inner;  // ERROR
        }
        elsef if (MappingType == EPropertyType::EnumAsByteProperty)
        {
        }
        
    };
} Property <optimize=false>;

010 Editor does support recursive structs but you have to do a forward declaration by including this line before the struct declaration:

struct Property;

For example:

struct Property;
    
typedef struct
{
    ...
    Property inner;
    ...
} Property <optimize=false>;

Let us know if you can’t get it to work. Cheers!

Graeme
SweetScape Software

I am glad that I came across this post, as it isn’t exactly clear how to forward-delare a typedef from the docs.

I also want to add that trying to do the following, which I tried before, crashes the whole editor:

typedef struct Property;
    
typedef struct
{
    ...
    Property inner;
    ...
} Property <optimize=false>;

Generally, I prefer the typdef variant because I can add attributes etc. to the value, which does not seem to work for “normal” structs.

We are missing an example in the help file about using recursive structs and typedefs and we’ll get one added. I believe we have the crash fixed now for the code you sent and we’ll get the fix into our next release.

Graeme
SweetScape Software

1 Like