Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

TEnumAsByte is not intended for use with enum classes?

Is this just a UBT bug? I'm getting

 TEnumAsByte is not intended for use with enum classes - please derive your enum class from uint8 instead.
 note: see declaration of 'TEnumAsByte_EnumClass<true>
 note: see reference to class template instantiation 'TEnumAsByte<EFNCellularReturnType>' being compiled

However, my code is as follows:

 enum class EFNCellularReturnType : uint8
     CellValue     UMETA(DisplayName="CellValue"),
     NoiseLookup     UMETA(DisplayName="NoiseLookup"),
     Distance     UMETA(DisplayName="Distance"),
     Distance2     UMETA(DisplayName="Distance2"),
     Distance2Add UMETA(DisplayName="Distance2Add"),
     Distance2Sub UMETA(DisplayName="Distance2Sub"),
     Distance2Mul UMETA(DisplayName="Distance2Mul"),
     Distance2Div UMETA(DisplayName="Distance2Div")


 UFUNCTION(BlueprintCallable, meta = (DisplayName = "SetCellularReturnType", Keywords = ""), Category = "FastNoise")
     void K2_SetCellularReturnType(TEnumAsByte<EFNCellularReturnType> cellularReturnType) { SetCellularReturnType(cellularReturnType); }
     UFUNCTION(BlueprintCallable, meta = (DisplayName = "GetCellularReturnType", Keywords = ""), Category = "FastNoise")
     TEnumAsByte<EFNCellularReturnType> K2_GetCellularReturnType() const { return GetCellularReturnType(); }

I have 4 other enums in the same format.

 enum class EFNNoiseType : uint8
     Value           UMETA(DisplayName="Value"),
     ValueFractal   UMETA(DisplayName="ValueFractal"),
     Perlin           UMETA(DisplayName="Perlin"),
     PerlinFractal  UMETA(DisplayName="PerlinFractal"),
     Simplex           UMETA(DisplayName="Simplex"),
     SimplexFractal UMETA(DisplayName="SimplexFractal"),
     Cellular       UMETA(DisplayName="Cellular"),
     WhiteNoise       UMETA(DisplayName="WhiteNoise"),
     Cubic           UMETA(DisplayName="Cubic"),
     CubicFractal   UMETA(DisplayName="CubicFractal")
 enum class EFNInterp : uint8
     Linear    UMETA(DisplayName="Linear"),
     Hermite    UMETA(DisplayName="Hermite"),
     Quintic    UMETA(DisplayName="Quintic")
 enum class EFNFractalType : uint8
     FBM           UMETA(DisplayName="FBM"),
     Billow       UMETA(DisplayName="Billow"),
     RigidMulti UMETA(DisplayName="RigidMulti")
 enum class EFNCellularDistanceFunction : uint8
     Euclidean UMETA(DisplayName="Euclidean"),
     Manhattan UMETA(DisplayName="Manhattan"),
     Natural      UMETA(DisplayName="Natural")

The generated header file seems to be where the warning originates. In the generated header of file that include the header that has the enums, it forward declares the enums as follows

 enum class EFNCellularReturnType : uint8;
 enum class EFNCellularDistanceFunction : uint8;
 enum class EFNFractalType : uint8;
 enum class EFNNoiseType : uint8;
 enum class EFNInterp : uint8;

Here is te generated function calls which are generated in the same way as the rest of the enums

 DECLARE_FUNCTION(execK2_GetCellularReturnType) \
     { \
         P_FINISH; \
         P_NATIVE_BEGIN; \
         *(EFNCellularReturnType*)Z_Param__Result=this->K2_GetCellularReturnType(); \
         P_NATIVE_END; \
     } \
     DECLARE_FUNCTION(execK2_SetCellularReturnType) \
     { \
         P_GET_ENUM(EFNCellularReturnType,Z_Param_cellularReturnType); \
         P_FINISH; \
         P_NATIVE_BEGIN; \
         this->K2_SetCellularReturnType(EFNCellularReturnType(Z_Param_cellularReturnType)); \
         P_NATIVE_END; \
     } \

The project still builds but this warning is driving me mad. If anyone can see something that I can't, please let me know. If this is a bug, please let me know. I've spent far too long trying to rename it, change it's values, rename it's values, made it the first emun, put it in the middle. No matter what I do, it is always this enum mentioned in the warnings. Any help is much appreciated.

Product Version: UE 4.18
more ▼

asked Jan 07 '18 at 02:42 PM in C++ Programming

avatar image

822 38 39 241

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

2 answers: sort voted first

Hey there, afaik TEnumAsBytes is only intended for typical enums (not class enums). For class enums i believe you can use the type directly without TEnumAsBytes.

more ▼

answered Jan 08 '18 at 10:32 AM

avatar image

6k 162 129 305

avatar image MJ_01 Jan 09 '18 at 01:37 AM

You are correct. It is no longer complaining after I removed TEnumAsByte on all my enums. However, the reason I added TEnumAsByte in the first place was because I got an error and it was complaining that I didn't have it in the first place. I also had other errors that I have since resolved since that build attempt.

avatar image xlar8or Jan 09 '18 at 12:42 PM

So everything is working now?

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

I'm using 4.20.2 and I was having some problems getting enums working correctly while trying to pass them as a function parameter.

Using the namespace enum technique along with the TEnumAsByte in the function parameter worked for me.

more ▼

answered Sep 30 '18 at 03:35 PM

avatar image

31 1 2 2

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question