x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

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?

Product Version: UE 4.15
Tags:
more ▼

asked May 14 '17 at 07:41 AM in C++ Programming

avatar image

devast3d
242 15 19 47

avatar image BrUnO XaVIeR May 14 '17 at 05:54 PM

UPROPERTY() is already a Macro.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

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

more ▼

answered May 14 '17 at 07:43 PM

avatar image

Shadowriver
37.2k 936 172 1116

avatar image devast3d May 15 '17 at 07:53 AM

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.

avatar image Shadowriver May 15 '17 at 04:28 PM

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

avatar image WHSolv Jun 26 '17 at 06:47 AM

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 ();

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question