Const Prop Omitted from UHT for Class Member Vars

Hi,

Looking at the UHT parsing code, it cannot handle Const UProp declarations in member vars. I am under the assumption that this is a bug since none of the documentation mentions this restriction. I checked the version of the HeaderParser file available on GitHub and it appears that it has not been addressed, yet.

Thanks

Hi,

What property type are you trying to declare? We do support:

const UObject* Value;

We do not support (but we do handle it in UHT with a message ‘Inappropriate keyword ‘const’ on variable of type…’)

const float Value;

We’re aware there’s an issue with (as in it doesn’t tell you what’s wrong exactly, there’s a ticket to fix thius):

UObject const* Value;

Unfortunately we’re probably never going to make UHT as good as any C++ compiler, there’s some limitations we’re aware of but we’re trying to make it better. Also note that ‘const’ values do not necessarily mean much when it comes to UObjects, You will always be able to set them through reflection (UProperties etc). We only care for VisibleAnywhere, EditAnywhere UPROPERTY keywords in the editor.

Hi,

I guess what I meant to say was specifier. This is akin to what I was attempting to do:

UPROPERTY(Const)
uint32 Value;

According to the documentation, this should be valid.
https://docs.unrealengine.com/latest/INT/Programming/UnrealArchitecture/Reference/Properties/Specifiers/Const/index.html

I was hoping that this would enforce const-ness through the engine, post initialization.

Thanks

I guess maybe that’s not mentioned there but that’s an ‘old-style’ function param specifier:

UFUNCTION(BlueprintCallable, Category="Test")
static void DoSomething(UPARAM(const) float Value);

And is basically the equivalent of just normal ‘const float Value’ these days.

Ah, alright. Thanks. :slight_smile: