Trying to simplify writing boiler plate, but I get Field cannot have type 'void'
and / or Expected ')'
Newbie c++, I've seen a bunch questions like this, but still can't figure it out. The errors are still too cryptic to me to able to google them..
#define GAME_STAT(Stat) \
UPROPERTY(BlueprintReadOnly, Category = "Stats", ReplicatedUsing = OnRep_##Stat##) \
FGameplayAttributeData ##Stat##; \
GAME_STAT_ACCESS(UGameStats, ##Stat##); \
UFUNCTION() \
virtual void OnRep_##Stat##(const FGameplayAttributeData& Old##Stat##);
GAME_STAT("Health")
I want to generate the code with word "Health" instead of stand-in "Stat"
Thanks!
##
is for pasting tokens together, but it looks like you think it is "reverse stringification".
It's also a binary operator, not an "around-ary" operator.
That is,
#define hello(x) Hello_##x
hello(World)
will produce
Hello_World
This should work (but is thoroughly untested):
#define GAME_STAT(Stat) \
UPROPERTY(BlueprintReadOnly, Category = "Stats", ReplicatedUsing = OnRep_##Stat) \
FGameplayAttributeData Stat; \
GAME_STAT_ACCESS(UGameStats, Stat); \
UFUNCTION() \
virtual void OnRep_##Stat(const FGameplayAttributeData& Old##Stat);
GAME_STAT(Health)