Can you avoid the reflection system when the subject is an struct?

In the case where I need to create a struct and avoid UE4 GC at all, controlling (manually) a struct lifetime, removing data from the memory and nullifying the references/pointers without the GC intervention myself. It’s possible to declare a struct without tagging it as an USTRUCT? The compiler keeps warning me that the type is undefined and must be a UCLASS, USTRUCT or UENUM.

Here is the error:

Here is the snippet: BlackHoleSkill.h -

Inserting a forward declaration or writing struct in the parameter list found in the line 221 didn’t solve the issue.

Personally, I didn’t find an answer for it.

Thanks! :slight_smile:

I believe you need to add USTRUCT() on the top of your FBlackHoleOrbitDdata + GENERATED_BODY() right before the first var.

Thanks for your reply.

I know, but in this case, I need a non-reflected struct, that’s why I removed both the USTRUCT as the GENERATE BODY tags. I will manage its lifetime by myself, I wanna know why this isn’t working.

Btw, if I comment the UFUNCTION() tag, the code compiles, but it leads to an engine crash (related to a FName error), because I’m calling the function in this snippet:



I guess it’s something related to the BindUFunction. I believe that the method doesn’t accept an non-reflected argument, inducing the compiler to tell me that the type is undefined and must be an UCLASS, USTRUCT or an UENUM…?

UFUNCTION itself only supports reflected params AFAIK. BindUFunction requires the function to be a UFUNCTION so it also requires reflected args.

So that’s the reason behind this compilation error, my initial thoughts aren’t wrong.

Thanks again for your support :slight_smile:

1 Like