FProperty::StaticClass() returns FFieldClass instead of UClass

Hello there!

I am new to C++ scripting in Unreal and am trying to upgrade a plugin from 4.22 to 4.25.

For the 4.22 version, the code looked like this:


UProperty::StaticClass()

which returned a type UClass *

Now the 4.25 version, like this:


FProperty::StaticClass()

returns a type FFieldClass *

Looking at the documentation of FProperty there seem to be 2 versions of the StaticClass() Method. How can I make it return the UClass * version?

Sorry if the answer is very obvious, but I couldn’t find anything online.
Thanks in advance!

The compiler automatically resolves which overloaded function should be called based on the return type.



FProperty prop;

//Returns a UClass pointer
UClass* propClass = prop::StaticClass();

//Returns a FFieldClass pointer
FFieldClass* propFieldClass = prop::StaticClass();

Posting a snippet might help figuring out why it’s returning the wrong type.

Thank you, I’m trying to pass the UClass * as an argument to a function call AddProperty() while iterating over different value types.



auto AddProperty = &](const FName& Name, UClass* PropClass, UScriptStruct* Struct = NULL) { ... }

auto CollectProperties = &](MyElement* Element)
{
  for (auto It = Element->IntValues.CreateIterator(); It; ++It)
    // When compiling i get the following error:
    // error C2664: 'void MyPlugin::MyFunction::<lambda_f7a202816d4305339f3c5d82defbfb03>::operator ()(const FName &,UClass *,UScriptStruct *) const': cannot convert argument 2 from 'FFieldClass *' to 'UClass *'
    // note: Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
    AddProperty(It->Key, FIntProperty::StaticClass());
  for (auto It = Element->FloatValues.CreateIterator(); It; ++It)
    // Same error here
    AddProperty(It->Key, FFloatProperty::StaticClass());
}


Declaring a UClass* variable first doesn’t work either.



// When compiling i get the following error:
// error C2440: 'initializing': cannot convert from 'FFieldClass *' to 'UClass *'
// note: Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
UClass* propClass = FProperty::StaticClass();


This code used to work for version 4.22 using the UIntProperty::StaticClass() and UFloatProperty::StaticClass().

Odd. Might be a bug.