UCLASS, UFUNCTION support inside macros request

It’s will be great if we will able to place UCLASS, UFUNCTION, etc inside macros and it will be work after substitution.

For example, higher level code generation.

#define DECLARE_SUPERCLASS(cls_name) \
   class MY_API U##cls_name : public UObject\

Thanks :slight_smile:

Yeah it doesn’t like the GENERATED_BODY() or UPROPERTY( )

You’ll probably need another way to generate this code.

This works for me:

#define DECLARE_SUPERCLASS(api_name, cls_name) \
class api_name U##cls_name : public UObject\

I tested in a engine plugin, which is why I substituted the MY_API with the argument.

I’ve tested this and got error ../Classes/Utils.h(1): error : Missing 'class' in Class declaration Missing 'class' in Class declaration.


This is a normal behavior because UHT parse header before compiler replace macro.

The solution will be to replace some kind of macro with UHT, parse to scan UCLASS and UFUNCTION properties, and finally compiler replace last macros. Hope one day Epic improve this tool :slight_smile: