Need help with custom macro

Hi. I made a macro

#pragma once
#include "CoreMinimal.h"
#include "UObject/ObjectMacros.h"

#define DECLARE_ENUM(EnumName, ...) \
UENUM(BlueprintType) \
enum class EnumName : uint8 { \
__VA_ARGS__, \
EnumName##_Count UMETA(Hidden) \
};

Made enum

#pragma once
#include "CoreMinimal.h"
#include "EnumUtils.h"

DECLARE_ENUM(ERifledType,
	Default UMETA(DisplayName="Default"),
	AK UMETA(DisplayName="AK"),
	AR15 UMETA(DisplayName="AR15"),
	AR10 UMETA(DisplayName="AR10"),
	BrowningM2 UMETA(DisplayName="BrowningM2")
)

When using “UPROPERTY”

	UPROPERTY(Config, EditAnywhere, BlueprintReadWrite)
	ERifledType RifledType;

I get an error -

Error : Unable to find ‘class’, ‘delegate’, ‘enum’, or ‘struct’ with name ‘ERifledType’

How do I fix my macro so it works with “UPROPERTY”?

try

UENUM(BlueprintType) enum  ERifledType
{
	Default UMETA(DisplayName="Default"),
	AK UMETA(DisplayName="AK"),
	AR15 UMETA(DisplayName="AR15"),
	AR10 UMETA(DisplayName="AR10"),
	BrowningM2 UMETA(DisplayName="BrowningM2")
};

To provide some additional context: You cannot embed the various U-macros inside of other macros. It makes them effectively invisible to UnrealHeaderTool and results in the project acting as if you had declared the enum/struct/class/etc without the U-macro at all.

Also as a minor edit to eldany.uy’s suggestion, the enum should be declared:

UENUM(BlueprintType)
enum class ERifledType : uint8

There’s also no real reason to have those DisplayName meta’s there. Given the names of the enum values themselves, the default display name will be identical to what you are manually writing.