UENUM compilation issue

I am having an issue with UENUM and .generated.* files.

So, I am using TEnumAsByte in my code file which works fine but the .generated.* files directly specify the enum instead of using TEnumAsByte which then throws compilation errors.

It is solved by manually adding TEnumAsByte in .generated files but then I have to compile the same project 2 times while manually adding TEnumAsByte.

I tried moving enums to the same header as my class,
converting them to an enum class uint8,
putting them inside namespaces and vice-versa,
recompiling, updating all vs files,
changing unreal version,
but nothing seems to work.

Please help me its so annoying.

Sure, here it is

File: ExternalEnums.h

enum class EAIAlertnessLevel : uint8 // I also tried without class and using namespace
 	AlertnessLevelNone = 0	UMETA(DisplayName="None"),
 	Curious				UMETA(DisplayName="Curious"),
 	Alert					UMETA(DisplayName="Alert"),
	Fight				UMETA(DisplayName="Fight")

File: MyClass.h

// Throws compilation error
UFUNCTION(BlueprintNativeEvent) // Works fine when not exposed to blueprints
void IncreaseAIAlertness(TEnumAsByte<EAIAlertnessLevel> CurrentAlertness);

Also the code in .gen.* file which actually causes the error


virtual void IncreaseAIAlertness_Implementation(EAIAlertnessLevel CurrentAlertness);


static FName NAME_ANormalBulletBase_IncreaseAIAlertness = FName(TEXT("IncreaseAIAlertness"));
void AMyClass::IncreaseAIAlertness(EAIAlertnessLevel CurrentAlertness)


1>{$ProjectDir}/Intermediate/Build/Win64/UE4Editor/Inc/{$ProjectName}/MyClass.gen.cpp(110): error C2511: 'void AMyClass::IncreaseAIAlertness(EAIAlertnessLevel)': overloaded member function not found in 'AMyClass'
1>  {$ProjectName}\Source\{$ProjectName}/Player/Bullets/MyClass.h(17): note: see declaration of 'AMyClass'
1>{$ProjectDir}/Intermediate/Build/Win64/UE4Editor/Inc/{$ProjectName}/MyClass.gen.cpp(115): error C2352: 'UObject::FindFunctionChecked': illegal call of non-static member function
1>  F:\EpicGamesLibrary\UE_4.26\Engine\Source\Runtime\CoreUObject\Public\UObject/Object.h(1028): note: see declaration of 'UObject::FindFunctionChecked'
1>F:\EpicGamesLibrary\UE_4.26\Engine\Source\Runtime\Core\Public\Containers/EnumAsByte.h(20): warning C4996: 'TEnumAsByte_EnumClass<true>': TEnumAsByte is not intended for use with enum classes - please derive your enum class from uint8 instead. Please update your code to the new API before upgrading to the next release, otherwise your project will no longer compile.
1>  F:\EpicGamesLibrary\UE_4.26\Engine\Source\Runtime\Core\Public\Containers/EnumAsByte.h(10): note: see declaration of 'TEnumAsByte_EnumClass'

I already did all of this.

I think the problem is with UHT because as soon as I change EAIAlertnessLevel into TEnumAsByte in .generated files, the project compiles without any errors.

Because I need it in blueprints. Its also gives the same error if I use UPROPERTY(BlueprintReadOnly/BlueprintReadWrite) TEnumAsByte Var0;

Its says that for the function is .generated files.
If I remove the UFUNCTION() from my original function (in MyClass.h) or change EAIAlertnessLevel into TEnumAsByte in .generated files, it works fine.

Can you post the code?

What you can do is

Remove additional specifier class from enum declaration also I’m not very using uint8 here. You can also use without it. :

 enum EAIAlertnessLevel : uint8 // remove class at here
     AlertnessLevelNone = 0    UMETA(DisplayName="None"),
     Curious                UMETA(DisplayName="Curious"),
     Alert                    UMETA(DisplayName="Alert"),
     Fight                UMETA(DisplayName="Fight")

Next. You need to show its referance point to compiler, thus need to include. Additionally, while signing your function, you dont need TEnumAsByte or you can put depens on you, can do like several ways

Put your reference

include "ExternalEnums.h"
UFUNCTION(BlueprintNativeEvent) // Works fine when not exposed to blueprints
void IncreaseAIAlertness(EAIAlertnessLevel CurrentAlertness);

I suggest to include your libs in cpp. Thus in the header file, to increase your compilation speed, you can always pretell compiler as this is `class` will be used in cpp and dont use `include` in your header.

class EAIAlertnessLevel; // do after include tab before UCLASS()

void IncreaseAIAlertness(EAIAlertnessLevel CurrentAlertness);
virtual void IncreaseAIAlertness_Implementation(EAIAlertnessLevel CurrentAlertness)

Check the answer below :slight_smile:

why did you marked with BlueprintNativeEvent

can you check the call points of this function, it says overloaded member not found, seems like you make a wrong call.

Can you attach MyClass.h and ExternalEnums.h here?

Can you remove → include “ExternalEnums.generated.h” from your ExternalEnums.h?

error logs are same ?


It won’t let me upload .h files soooooo…

Didn’t work


this problem was related with implementation fundementals of BlueprintNativeEven that dont need to use TEnumAsByte as type.