I am trying to define a simple enumeration in a header file as per the example published here. My header file consists of the following:

#pragma once

#include "CoreMinimal.h"

enum class MyEnum : int32

If I remove UENUM(), the compiler doesn't complain; however, when I add it, I get multiple errors.

  • expected a ';'

  • expected a '{'

  • identifier "MyField1" is undefined

  • identifier "MyField2" is undefined

  • identifier "MyField3" is undefined

This all seems odd considering I'm doing exactly what the article says to do and other websites suggest doing the same thing.

Here's what it looks like in my editor:

enter image description here

What I've tried

  • Changing enum class to simply enum.
  • Not explicitly specifying an underlying type.
  • Defining the enum elsewhere (for instance, in one of my classes; but when you add UENUM() there, it tells you you can't define it there).

I am new to both C++ and UE4 so it could be silly or trivial. Either way, I'm having a hard time understanding why something so simple won't compile.

  • \$\begingroup\$ I don't know much Unreal, but reading through the example I see this comment which seems like it might be relevant: //"BlueprintType" is essential to include — did you try including that inside the parentheses? \$\endgroup\$
    – DMGregory
    Commented Apr 26, 2018 at 20:55
  • \$\begingroup\$ I don't need it for BP so no. Examples elsewhere don't even mention it. When I defined it in a class, the compiler never complained about it so I doubt a missing argument is the issue. \$\endgroup\$
    – Imagin
    Commented Apr 26, 2018 at 21:03
  • \$\begingroup\$ Do you really get errors, or do you get red squigglies in your editor? Try compiling; Visual Studio doesn't actually understand how Unreal works, so it's pretty common for it to make red squigglies in places. \$\endgroup\$
    – anon
    Commented May 19, 2019 at 6:50
  • \$\begingroup\$ For anyone who may be experiencing this, in UE4 atleast I could only compile UENUMS with flags if the base type was uint8, and not int32. \$\endgroup\$
    – Weston
    Commented Sep 16, 2022 at 18:57

1 Answer 1


You would expect these errors if the macro UENUM is not defined, which means the compiler tries to interpret UENUM() enum class as a function definition.

I'm not familiar with the UDK API, but from browsing some examples it looks like the UENUM macro is defined in 'UObject/ObjectMacros.h', so you should include that file as well after CoreMinimal.h


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .