Hey folks,
It looks like the GetValueAsName function, in Class.h on line 3393 is still referencing a function that was deleted in 5.8. Specifcally “StaticEnum”.
I’ve checked the 5.8 Release branch, and ue5_main and it seems to still be present there in both. Just wanted to flag it as it’s stopping us from compiling.
Many thanks,
David
EDIT:
Investigating further, I’m not sure if it’s a case of “deleted code wasn’t removed from all cases”, but perhaps I need to implement something to support the new way of doing things. I’m unfamiliar with C++'s Concepts feature, so I think I need to do some reading.
Is there any general advice for anyone called “GetValueAsName” with their own enums?
Many thanks
[Attachment Removed]
Hi David,
Sorry for this. You’ve probably fallen afoul of trying to call it with an incomplete type, e.g.:
enum class EMyEnum : uint32;
void Func()
{
UEnum* Enum = StaticEnum<EMyEnum>(); // error, function is deleted
}
You should add the include instead of a forward declaration:
#include "MyEnum.h"
void Func()
{
UEnum* Enum = StaticEnum<EMyEnum>(); // works
}
This would previously compile and sometimes link, depending on if a proper instantiation of StaticEnum<EMyEnum>() with the full type happens elsewhere. Now it always fails to compile.
The UE::CUEnum concept requires the existence of a StaticEnum<T>() implementation to determine if T is a UEnum rather than a regular enum, which you can’t tell from a simple forward declaration. By requiring the full type for both calling StaticEnum<T>() and using UE::CUEnum, we can detect this effectively.
I will put a comment on the function to guide users to the likely solution if they hit the same problem you did.
Steve
[Attachment Removed]
Hey Steve,
Thanks for the hint! Unfortunately it looks to be a little more complicated. The hash include for the enum in question is actually already present. However the enum in question isn’t an enum class.
It is structured as such:
UENUM(BlueprintType)
namespace (EMyEnumType)
{
enum Enum
{
Type1,
Type2
};
}
Then again I may have a solution now after having typed that out. I’ll give it a shot.
But while I do that, my question in the meantime is: should that still compile? Is that still a valid way to do things following the change to StaticEnum?
Many thanks,
David
[Attachment Removed]
Can you check your .generated.h file to see if it contains a StaticEnum<EMyEnumType::Enum>() declaration for your enum type? This should work whether it’s an enum class or regular enum.
Steve
[Attachment Removed]
Hey, I’ve cracked it. And yes I can use the .generated.h as the proof.
What fixed it was:
UENUM(BlueprintType)
namespace (EMyEnumType)
{
enum Enum : uint8
{
Type1,
Type2
};
}
Adding the size type seemed to kick the machine into gear. With it, I can see the StaticEnum in the generated header, without it, the function def isn’t generated.
Many thanks,
David
[Attachment Removed]
Right, glad you found it! In my tests, a non-class enum without an underlying type was rejected. This can be controlled by a config entry:
[UnrealHeaderTool]
EnumUnderlyingTypeNotSet=Disallow
This should start rejecting all such enums and will allow you to track down your issues and fix them.
Steve
[Attachment Removed]