C2955 'TEnumAsByte': use of class template requires template argument list

Hello Fellow Devs!

My team and I are currently migrating our project from UE4.27 to UE5.3.
The project builds properly on 4.27, but on 5.3.1 I get the following errors on enums in a xyz.gen.cpp file:

The error applies to several enums with nearly identical definitions, such as this one:

Usage of the enum in xyz.cpp:

From what I understand, using TEnumToByte<> is the proper way to define member variables with enums, so I’m unsure what the alternative is.

Any suggestion?
Thanks in advance!

This was a very, very old way that Unreal supported enums. It was obsolete even in 4.27.

What you should be doing is using a more modern C++ feature, enum class:

UENUM(BlueprintType)
enum class EMatchmakingQueue : uint8
{
      ...
};

Once you do that, you don’t need the TEnumAsByte wrapper at all and you can just make properties and parameters of type EMatchmakingQueue directly.

You should have been getting other errors from the fact your enum doesn’t start with an ‘E’, but that’s besides the point.

1 Like

Thanks for the heads-up!

I guess that’s the issue when learning UE4 with books like O’Reilly :smile:

For the “E” start, I thought it was only a convention. Are there now stronger restrictions for naming data types?

I thought that the ‘E’ prefix was mandated the same as the ‘F’, ‘U’ and ‘A’ ones were. But it doesn’t seem like it. Maybe they dropped that enforcement or it’s a bug introduced in the rewrite of UHT.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.