(4.5) Scoped Enumeration as UFUNCTION compile error

While trying to pass a scoped enumerator to a UFUNCTION’d method, I receive the following compile error:

error C3431: ‘ETestEnum’ : a scoped
enumeration cannot be redeclared as an
unscoped enumeration

This is how I’m using it:

UENUM()
enum class ETestEnum : uint8
{
    TestItem
};

UCLASS(Blueprintable)
class ATestClass : AActor
{
    UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Objective")
	ETestEnum TestProp; //OK

    void TestMethod(ETestEnum MyEnum); //OK

    UFUNCTION()
    void TestUFunc(ETestEnum MyEnum); //error c3431
};

Is this a symptom of ‘currently in development’ or am I using it wrong for UE4?

The UHT is generating code that tries to do the following:

struct ATestClass_eventTestUFunc_Parms
{
	TEnumAsByte<enum ETestEnum> MyEnum;
};

That is what’s causing the build error you’re seeing (if you remove the enum or add the class, the error goes away).

I’ll pass this over to the relevant person.

Thanks.

It seems this was already fixed.

You should just need to merge over the following into your 4.5 branch: https://github.com/EpicGames/UnrealEngine/commit/53d7de0fc81014ca734f497cf0eef81016f319e8

Excellent, thanks for the link!

The 404 is likely because you’re either not signed into GitHub, or you don’t have your GitHub account linked to your unrealengine.com account.

I don’t think this was merged into 4.5 (although it wasn’t my change), however since you already have 4.5 installed, the simplest thing would be to try it and see.

I’ll email our integrations team to get this merged into the 4.5 release (if it isn’t already).

Thanks.

Is this fixed in version 4.5 installed through the launcher or do I need to go and get the github version?

I went and tested it with 4.5 and I get the same problem:

Error	1	error C3431: 'ETileType' : a scoped enumeration cannot be redeclared as an unscoped enumerationd:\projects\unreal engine\projectberyl\source\projectberyl\LevelData.h(17) : error C3431: 'ETileType' : a scoped enumeration cannot be redeclared as an unscoped enumeration	d:\projects\unreal engine\projectberyl\source\projectberyl\LevelData.h	17	1	ProjectBeryl
Error	2	error C3431: 'ETileType' : a scoped enumeration cannot be redeclared as an unscoped enumeration	D:\Projects\Unreal Engine\ProjectBeryl\Source\ProjectBeryl\LevelData.h	17	1	ProjectBeryl
Error	3	error C3431: 'ETileType' : a scoped enumeration cannot be redeclared as an unscoped enumeration	D:\Projects\Unreal Engine\ProjectBeryl\Intermediate\Build\Win64\Inc\ProjectBeryl\ProjectBeryl.generated.cpp	95	1	ProjectBeryl
Error	4	error C3431: 'ETileType' : a scoped enumeration cannot be redeclared as an unscoped enumeration	D:\Projects\Unreal Engine\ProjectBeryl\Intermediate\Build\Win64\Inc\ProjectBeryl\ProjectBeryl.generated.cpp	124	1	ProjectBeryl

Is there any workaround for now so I wouldn’t need to go fiddle with the github version?

Not really - you could just use an enum nested in a struct instead.

struct ETileType
{
    enum Enum
    {
        Entry1,
        Entry2,
    };
};

You’d still use the ETileType::Entry1 syntax when using an entry from it, although the type would have to be ETileType::Enum rather than just ETileType.

I’ll ask integrations to merge it over, but I can’t say when it will actually make it out in a binary release.

STILL an issue in 4.8…

void ScanListSmartProp(UStaticMeshComponent * object, TArray & BakedParts, TEnumAsByte<BuildPart_Types::BuildPart_Type> SmartObjectType);