UENUM inside of class: 'Enum' is not allowed here

I am currently trying to convert my project rom 4.11 to 4.12.

I have some enums like the following:

UCLASS()
class PROJECT_API AMyActor : public AActor
{
	GENERATED_BODY()
	
public:	
[...]

	UENUM(BlueprintType)
	enum class EPieceColor : uint8
	{
		PIECE_COLOR_UNKNOWN UMETA(DisplayName = "Unknown"),
[...]

Since 4.12 this always gives me:

‘Enum’ is not allowed here

I think I can either

  • move the enum out of the class
  • not use the enum for UPROPERTY variables

But is there a way to have UENUM inside the class so I can have the class scope for my enum AND be able to use it for UPROPERTY variables?

1 Like

Hi,

“UCLASS, UENUM etc. declarations are now illegal outside of global scope. If you have a type which is nested inside a UCLASS or USTRUCT, they should be moved to global scope.”

This was a design decision to avoid a lot of extra overhead and partial implementations for a barely-used feature.

Steve

1 Like

Hi Steve,
thank you very much for the information.

Just in case you have the time, can you tell me how I would have been able to find this information myself, without you?

How did YOU find it?

Thanks for the fast answer, I’ll move my enums to global scope. :frowning:
Without your answer I would have tried to get around this somehow.

Thanks!

It was easy for me to find, because I made that change and wrote the corresponding release note. :slight_smile:

In general, if you find something doesn’t work from one version to the next, look at the ‘Upgrade Notes’ section of the release notes. In theory, all breaking changes should be listed there.

Of course, sometimes things just break - then we rely on users to report them.

Steve

1 Like