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"

Const UProperty specifier unknown

Hi!

The "const" specifier for UProperties is unknown to UHT:

 USTRUCT()
 struct Foo
 {
     GENERATED_USTRUCT_BODY()
 
     UPROPERTY( Const )
     float Bar;
 };
 
 In TemporaryUHTHeader_Foo: Unknown variable specifier 'Const'

Is there any reason for it, is it a legacy thing?

Product Version: Not Selected
Tags:
more ▼

asked Mar 26 '15 at 03:29 PM in C++ Programming

avatar image

G4m4
695 27 15 34

avatar image Astronovice Sep 15 '15 at 07:19 AM

I have the same question. According to this: https://docs.unrealengine.com/latest/INT/Programming/UnrealArchitecture/Reference/Properties/Specifiers/Const/index.html the Const specifier is valid for UProperties.

avatar image WHSolv Jun 21 '17 at 06:20 AM

Nothing new so far?

avatar image Vawx Jun 23 '17 at 02:53 AM

It's const but you didn't give it a value. Maybe that is the issue?

avatar image WHSolv Jun 23 '17 at 03:38 AM

What do you mean? If you are talking about default value like this

 UPROPERTY(Const)
 float SomeFloatVar = 1.f;

then it doesn't work either.

avatar image Vawx Jun 23 '17 at 03:57 AM

You're totally right. I looked into the ObjectMacros.h file and looked for "Const". It is strange because under:

     // valid keywords for the UPROPERTY macro

There is a Const.

I do not know why it is giving a compile issue. Must be used in a specific way in which I am not sure of.

Edit:

Here is a thread where a developer explains there is a limitation with this keyword:

https://forums.unrealengine.com/showthread.php?55244-UPROPERTY-and-consts

Here is a Wiki where it explains that Const causes a compiling error and to use the "Visible*" specifiers instead.

https://wiki.unrealengine.com/UPROPERTY#Const

avatar image WHSolv Jun 23 '17 at 05:08 AM

Yeah, I saw these links. And the right point of one of the comments in the first one is that a variable, being exposed to BP, shouldn't be changed anyhow neither inside C++, nor in BP. Yes, VisibleAnywhere, for example, provides read-only access in BP, but does absolutely nothing with C++, and that's the problem.

One of the "solutions" is make a UFUNCTION getter for non-exposed const variable, but it looks like a duct tape.

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

0 answers: sort voted first
Be the first one to answer this question
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