Using enum classes across modules.

I have an enumeration declared in separate .h file in my “Locomotion” module, declared as such:



#include "CoreMinimal.h"
#include "WallEntryType.generated.h"

UENUM(BlueprintType)
enum class EWallEntryType : uint8
{
    Bottom   UMETA(DisplayName = "Bottom"),
    Top      UMETA(DisplayName = "Top")
};


I want to include this enumeration in a different module, “InterfaceUtilities.” Nevertheless, trying to compile it, UHT complains that it can’t find the generated and header files and so on, since it is missing the “MODULENAME_API” macro. Nonetheless, adding the macro and changing the above to this:



#include "CoreMinimal.h"
#include "WallEntryType.generated.h"

UENUM(BlueprintType)
enum class LOCOMOTION_API EWallEntryType : uint8
{
    Bottom   UMETA(DisplayName = "Bottom"),
    Top      UMETA(DisplayName = "Top")
};


Spews out the error that the enum is of the wrong base type…

Is there a way to have simple enums like this usable across different modules?

Are you sure that you have included the Locomotion module in your InterfaceUtilities module’s .Build.cs file (and that there is not a circular build dependency)? I am not sure how to use the MODULENAME_API macro in this scenario, but I have used various engine enum classes (such as ESlateVisibility, defined in SlateWrapperTypes.h) which are not marked with the export macro.

Did you ever figure this out?

In this post Error : Missing '{' in 'Enum' - #4 by TheJamsh user “TheJamsh” said that “Enumerations don’t/can’t be tagged for DLL export. You can use them in other modules without that macro anyway”.

So try and remove the modulename macro and check if your include path is precise enough. If you are referencing the EWallEntryType enum from another module, try this:

#include "Locomotion/[precise folder path]/WallEntryType.h