Wrapping UPROPERTY with macro not working

I’m tired of following type of code in my actors

UPROPERTY(Category = Unit, EditAnywhere, BlueprintReadOnly)
float f0;
UPROPERTY(Category = Unit, EditAnywhere, BlueprintReadOnly)
float f1;
UPROPERTY(Category = Unit, EditAnywhere, BlueprintReadOnly)
float f2;
...
UPROPERTY(Category = Unit, EditAnywhere, BlueprintReadOnly)
float fN;

Makes the header unreadable. So I’m searching the way to define the group of properties using same parameters (better yet to be able to specify additional properties per field, but that’s next step). My first step was to wrap UPROPERTY into macro, but I can’t see the field in the details panel which kinda breaks the purpose.

#define TESTUPROP UPROPERTY(Category = Unit, EditAnywhere, BlueprintReadOnly)
TESTUPROP
float ff0;

What’s wrong with UHT in this case?

UPROPERTY() is already a Macro.

UPROPERTY() and other U"macros" are just dummies so they are ignored by C++ compiler, they just markers for UHT for code generation and it’s not used in C++ compilation process at all. Because UHT is not C++ compiler by it self it does not follow C++ principles and ignores most content of the C++ files, UHT only has task to read those specific macros and interprate what is below it (name and type of property, function names and there arguments) and base on that generate extra code to register code elements to reflection system (in other word UHT is already saves a lot of work and code file space), which later is compiled when actual C++ compilation happens by the compiler.

Because of that any redefinitions of those macros are not even put in to consideration by UHT, in matter of fact those macros don’t need to be defined at all for UHT, because as i said in begining the only reason why they defined in C++ is for compiler to ignore them instead of showing undenefied macro error.

What you trying to do would need to be implemented in UHT (either shortcuts that are you trying to do so UHT can read them or macro definition support) and my guess why no body did implement support for macro definition in UHT because

  1. Exactly to make file readable for newcomers (you don’t need to search for redefinition to guess what it means)
  2. It would require to reimplement whole C++ macro system in UHT which is more complex the UHT needs it for it’s task

Thanks for the explanations. Are there any plans to introduce groups of properties/functions? So that I don’t have to copy-paste practically the same property list above each property/function.

Don’t know, best you can do (asside of implementing feature yourself ;p) is post a feature request in feedback forum

Can’t we just add some decoration-level for such a purpose?
I look for the solution as well, since code generation (custom one) of code generation (UHT) is a pretty usefull for a vast of callbacks, that are to be implemented later in BP.

#define CODEGEN_BPEVENT_HEADER(prop, val) \
		UFUNCTION(BlueprintImplementableEvent, BlueprintCallable, Category = "HUD") \
		void On ##prop ##val ();

To create a result as, for example:

UFUNCTION(BlueprintImplementableEvent, BlueprintCallable, Category = "HUD")
void OnHealth0 ();


UFUNCTION(BlueprintImplementableEvent, BlueprintCallable, Category = "HUD")
void OnHealth25 ();

...

UFUNCTION(BlueprintImplementableEvent, BlueprintCallable, Category = "HUD")
void OnHealthN ();