# Enum in function parameter cause error

**URL:** <https://forums.unrealengine.com/t/enum-in-function-parameter-cause-error/475154>\
**Category:** Programming & Scripting\
**Tags:** unreal-engine\
**Created:** [November 29, 2020, 7:56am UTC](https://forums.unrealengine.com/t/enum-in-function-parameter-cause-error/475154 "2020-11-29T07:56:22Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![anonymous\_user\_04b5ac74](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_04b5ac74](https://forums.unrealengine.com/u/anonymous_user_04b5ac74)\
**Post date:** [November 29, 2020, 7:56am UTC](https://forums.unrealengine.com/t/enum-in-function-parameter-cause-error/475154/1 "2020-11-29T07:56:22Z")

</div>

i get the error **Declaration is incompatible with int32 AMyCharacter::GetLevel( Level) const**

Game.h

```
 UENUM(BlueprintType)
 enum class ECustomEnum : uint8
 {
     // 0 None
     None UMETA(DisplayName = "None"),
 }

```

Character.h

```
UFUNCTION(BlueprintCallable, Category = "character")
	virtual int32 GetLevel(ECustomEnum Level) const;

```

Character.cpp

```
 int32 AMyCharacter::GetLevel(ECustomEnum Level) const
 {
     return 1;
 }

```

---

<div class="post-metadata">

**Author:** ![EvilCleric](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@EvilCleric](https://forums.unrealengine.com/u/EvilCleric)\
**Post date:** [November 29, 2020, 8:40am UTC](https://forums.unrealengine.com/t/enum-in-function-parameter-cause-error/475154/2 "2020-11-29T08:40:05Z")

</div>

Is that the complete message? Also, is this code right?

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_04b5ac74](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_04b5ac74](https://forums.unrealengine.com/u/anonymous_user_04b5ac74)\
**Post date:** [November 29, 2020, 8:47am UTC](https://forums.unrealengine.com/t/enum-in-function-parameter-cause-error/475154/3 "2020-11-29T08:47:53Z")

</div>

Ok the the enum doesn’t hold the level

**But this structure is the same**

the main issue is that the enum as the func parameter is causing the error

```
 Declaration is incompatible with int32 AMyCharacter::GetLevel( <Error-Type> Level) const

```

---

<div class="post-metadata">

**Author:** ![EvilCleric](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@EvilCleric](https://forums.unrealengine.com/u/EvilCleric)\
**Post date:** [November 29, 2020, 11:33am UTC](https://forums.unrealengine.com/t/enum-in-function-parameter-cause-error/475154/4 "2020-11-29T11:33:01Z")

</div>

Sorry, apart from the missing **;** in the enum declaration, I still can’t see anything wrong with the code. It should compile.

---

<div class="post-metadata">

**Author:** ![Alekann01](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Alekann01](https://forums.unrealengine.com/u/Alekann01)\
**Post date:** [November 29, 2020, 12:13pm UTC](https://forums.unrealengine.com/t/enum-in-function-parameter-cause-error/475154/5 "2020-11-29T12:13:16Z")

</div>

Hi LS.master101

When you use Enums in blueprint functions, it’s best to declare them as bytes.

```
UFUNCTION(BlueprintCallable)
int32 MyFunction(TEnumAsByte<FMyCustomEnum> myEnum);

```

Hope this helps.

Alex
