# UENUM compilation issue

**URL:** <https://forums.unrealengine.com/t/uenum-compilation-issue/484818>\
**Category:** Programming & Scripting\
**Tags:** unreal-engine\
**Created:** [June 12, 2021, 10:38pm UTC](https://forums.unrealengine.com/t/uenum-compilation-issue/484818 "2021-06-12T22:38:20Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![rEb00t\_1001](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@rEb00t\_1001](https://forums.unrealengine.com/u/rEb00t_1001)\
**Post date:** [June 12, 2021, 10:38pm UTC](https://forums.unrealengine.com/t/uenum-compilation-issue/484818/1 "2021-06-12T22:38:20Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![CtnDev](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/ctndev/32/1133321_2.png) [@CtnDev](https://forums.unrealengine.com/u/CtnDev)\
**Post date:** [June 13, 2021, 10:24am UTC](https://forums.unrealengine.com/t/uenum-compilation-issue/484818/2 "2021-06-13T10:24:53Z")

</div>

Can you post the code?

---

<div class="post-metadata">

**Author:** ![rEb00t\_1001](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@rEb00t\_1001](https://forums.unrealengine.com/u/rEb00t_1001)\
**Post date:** [June 13, 2021, 11:08am UTC](https://forums.unrealengine.com/t/uenum-compilation-issue/484818/3 "2021-06-13T11:08:59Z")

</div>

Sure, here it is

File: ExternalEnums.h

```
UENUM(BlueprintType)
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);
```

---

<div class="post-metadata">

**Author:** ![rEb00t\_1001](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@rEb00t\_1001](https://forums.unrealengine.com/u/rEb00t_1001)\
**Post date:** [June 13, 2021, 11:17am UTC](https://forums.unrealengine.com/t/uenum-compilation-issue/484818/4 "2021-06-13T11:17:16Z")

</div>

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

MyClass.generated.h

```
virtual void IncreaseAIAlertness_Implementation(EAIAlertnessLevel CurrentAlertness);

```

MyClass.gen.cpp

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

---

<div class="post-metadata">

**Author:** ![CtnDev](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/ctndev/32/1133321_2.png) [@CtnDev](https://forums.unrealengine.com/u/CtnDev)\
**Post date:** [June 13, 2021, 11:21am UTC](https://forums.unrealengine.com/t/uenum-compilation-issue/484818/5 "2021-06-13T11:21:10Z")

</div>

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. :

```
UENUM(BlueprintType)
 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()

UFUNCTION(BlueprintNativeEvent)
void IncreaseAIAlertness(EAIAlertnessLevel CurrentAlertness);
virtual void IncreaseAIAlertness_Implementation(EAIAlertnessLevel CurrentAlertness)
```

---

<div class="post-metadata">

**Author:** ![rEb00t\_1001](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@rEb00t\_1001](https://forums.unrealengine.com/u/rEb00t_1001)\
**Post date:** [June 13, 2021, 11:23am UTC](https://forums.unrealengine.com/t/uenum-compilation-issue/484818/6 "2021-06-13T11:23:33Z")

</div>

Error:

```
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'
```

---

<div class="post-metadata">

**Author:** ![CtnDev](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/ctndev/32/1133321_2.png) [@CtnDev](https://forums.unrealengine.com/u/CtnDev)\
**Post date:** [June 13, 2021, 11:28am UTC](https://forums.unrealengine.com/t/uenum-compilation-issue/484818/7 "2021-06-13T11:28:52Z")

</div>

Check the answer below 🙂

---

<div class="post-metadata">

**Author:** ![rEb00t\_1001](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@rEb00t\_1001](https://forums.unrealengine.com/u/rEb00t_1001)\
**Post date:** [June 13, 2021, 11:37am UTC](https://forums.unrealengine.com/t/uenum-compilation-issue/484818/8 "2021-06-13T11:37:49Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![CtnDev](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/ctndev/32/1133321_2.png) [@CtnDev](https://forums.unrealengine.com/u/CtnDev)\
**Post date:** [June 13, 2021, 11:40am UTC](https://forums.unrealengine.com/t/uenum-compilation-issue/484818/9 "2021-06-13T11:40:50Z")

</div>

why did you marked with `BlueprintNativeEvent`

---

<div class="post-metadata">

**Author:** ![rEb00t\_1001](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@rEb00t\_1001](https://forums.unrealengine.com/u/rEb00t_1001)\
**Post date:** [June 13, 2021, 11:42am UTC](https://forums.unrealengine.com/t/uenum-compilation-issue/484818/10 "2021-06-13T11:42:59Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![CtnDev](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/ctndev/32/1133321_2.png) [@CtnDev](https://forums.unrealengine.com/u/CtnDev)\
**Post date:** [June 13, 2021, 11:45am UTC](https://forums.unrealengine.com/t/uenum-compilation-issue/484818/11 "2021-06-13T11:45:09Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![rEb00t\_1001](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@rEb00t\_1001](https://forums.unrealengine.com/u/rEb00t_1001)\
**Post date:** [June 13, 2021, 11:47am UTC](https://forums.unrealengine.com/t/uenum-compilation-issue/484818/12 "2021-06-13T11:47:58Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![CtnDev](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/ctndev/32/1133321_2.png) [@CtnDev](https://forums.unrealengine.com/u/CtnDev)\
**Post date:** [June 13, 2021, 11:53am UTC](https://forums.unrealengine.com/t/uenum-compilation-issue/484818/13 "2021-06-13T11:53:56Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![rEb00t\_1001](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@rEb00t\_1001](https://forums.unrealengine.com/u/rEb00t_1001)\
**Post date:** [June 13, 2021, 12:07pm UTC](https://forums.unrealengine.com/t/uenum-compilation-issue/484818/14 "2021-06-13T12:07:17Z")

</div>

Sure

 ![341381-myclass.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/f/3/b/f3bb3bcc753afabb4e296898fe5bf01cdf901e24.jpeg)

 ![341369-extenum.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/c/1/0/c10434e12556bdaea7b10d12964e3abee8dc1962.jpeg)

---

<div class="post-metadata">

**Author:** ![rEb00t\_1001](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@rEb00t\_1001](https://forums.unrealengine.com/u/rEb00t_1001)\
**Post date:** [June 13, 2021, 12:08pm UTC](https://forums.unrealengine.com/t/uenum-compilation-issue/484818/15 "2021-06-13T12:08:57Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![CtnDev](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/ctndev/32/1133321_2.png) [@CtnDev](https://forums.unrealengine.com/u/CtnDev)\
**Post date:** [June 13, 2021, 12:15pm UTC](https://forums.unrealengine.com/t/uenum-compilation-issue/484818/16 "2021-06-13T12:15:22Z")

</div>

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

  

 ![341360-gaknmdkig7.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/5/b/2/5b254b8529ce19ed41f8c564b4e2ae8844673684.png)

---

<div class="post-metadata">

**Author:** ![rEb00t\_1001](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@rEb00t\_1001](https://forums.unrealengine.com/u/rEb00t_1001)\
**Post date:** [June 13, 2021, 12:21pm UTC](https://forums.unrealengine.com/t/uenum-compilation-issue/484818/17 "2021-06-13T12:21:01Z")

</div>

Didn’t work

---

<div class="post-metadata">

**Author:** ![CtnDev](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/ctndev/32/1133321_2.png) [@CtnDev](https://forums.unrealengine.com/u/CtnDev)\
**Post date:** [June 13, 2021, 12:24pm UTC](https://forums.unrealengine.com/t/uenum-compilation-issue/484818/18 "2021-06-13T12:24:15Z")

</div>

error logs are same ?

---

<div class="post-metadata">

**Author:** ![rEb00t\_1001](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@rEb00t\_1001](https://forums.unrealengine.com/u/rEb00t_1001)\
**Post date:** [June 13, 2021, 12:27pm UTC](https://forums.unrealengine.com/t/uenum-compilation-issue/484818/19 "2021-06-13T12:27:24Z")

</div>

Yes…

---

<div class="post-metadata">

**Author:** ![CtnDev](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/ctndev/32/1133321_2.png) [@CtnDev](https://forums.unrealengine.com/u/CtnDev)\
**Post date:** [June 13, 2021, 1:41pm UTC](https://forums.unrealengine.com/t/uenum-compilation-issue/484818/20 "2021-06-13T13:41:55Z")

</div>

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