# Const UProperty specifier unknown

**URL:** <https://forums.unrealengine.com/t/const-uproperty-specifier-unknown/312699>\
**Category:** Programming & Scripting\
**Tags:** unreal-engine\
**Created:** [March 26, 2015, 3:29pm UTC](https://forums.unrealengine.com/t/const-uproperty-specifier-unknown/312699 "2015-03-26T15:29:02Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![G4m4](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@G4m4](https://forums.unrealengine.com/u/G4m4)\
**Post date:** [March 26, 2015, 3:29pm UTC](https://forums.unrealengine.com/t/const-uproperty-specifier-unknown/312699/1 "2015-03-26T15:29:02Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![Astronovice](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/astronovice/32/764364_2.png) [@Astronovice](https://forums.unrealengine.com/u/Astronovice)\
**Post date:** [September 15, 2015, 7:19am UTC](https://forums.unrealengine.com/t/const-uproperty-specifier-unknown/312699/2 "2015-09-15T07:19:21Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![WHSolv](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@WHSolv](https://forums.unrealengine.com/u/WHSolv)\
**Post date:** [June 21, 2017, 6:20am UTC](https://forums.unrealengine.com/t/const-uproperty-specifier-unknown/312699/3 "2017-06-21T06:20:07Z")

</div>

Nothing new so far?

---

<div class="post-metadata">

**Author:** ![Vawx](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Vawx](https://forums.unrealengine.com/u/Vawx)\
**Post date:** [June 23, 2017, 2:53am UTC](https://forums.unrealengine.com/t/const-uproperty-specifier-unknown/312699/4 "2017-06-23T02:53:47Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![WHSolv](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@WHSolv](https://forums.unrealengine.com/u/WHSolv)\
**Post date:** [June 23, 2017, 3:38am UTC](https://forums.unrealengine.com/t/const-uproperty-specifier-unknown/312699/5 "2017-06-23T03:38:43Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Vawx](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Vawx](https://forums.unrealengine.com/u/Vawx)\
**Post date:** [June 23, 2017, 3:57am UTC](https://forums.unrealengine.com/t/const-uproperty-specifier-unknown/312699/6 "2017-06-23T03:57:47Z")

</div>

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](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](https://wiki.unrealengine.com/UPROPERTY#Const)

---

<div class="post-metadata">

**Author:** ![WHSolv](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@WHSolv](https://forums.unrealengine.com/u/WHSolv)\
**Post date:** [June 23, 2017, 5:08am UTC](https://forums.unrealengine.com/t/const-uproperty-specifier-unknown/312699/7 "2017-06-23T05:08:51Z")

</div>

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.
