Q
Q
Quark2021-04-23 12:16:04
C++ / C#
Quark, 2021-04-23 12:16:04

How to use ENUM in another header file?

I declared ENUM in the AmbientMusicSystem header file and I can freely use it in it (as in cpp):

#pragma once

#include "CoreMinimal.h"
#include "Components/SceneComponent.h"
#include "AmbientMusicSystem.generated.h"


UENUM()
enum class EStressState : uint8 {
  Calm = 0 UMETA(DisplayName = "Calm"),
  Stress = 1 UMETA(DisplayName = "Stress"),
  Run = 2 UMETA(DisplayName = "Run"),

  Nothing = 3 UMETA(DisplayName = "Nothing")
};


However, when I try to instantiate this ENUM in a different header, I get the error:
60828f4582658937321390.png
Here's how I tried to instantiate it in a different header:
UCLASS()
class MYPROJECT4_API AChangeStressStateTriggerBox : public ATriggerBox
{
  EStressState toStressState;
};


How can I get around this error and freely instantiate ENUM in any headers?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
J
jcmvbkbc, 2021-04-23
@Quark_Hell

How can I get around this error and freely instantiate ENUM in any headers?

By including a header with a type definition before using that type.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question