Issue with variables named "None" within a struct

Greetings !

I found an issue that bothered me this morning:

-UHT will generate wrong property name for variables which are named “None” within a struct.

Example:

USTRUCT(BlueprintType)
struct FSTestStruct
{
	GENERATED_USTRUCT_BODY()

	UPROPERTY(EditAnywhere, Category = Defaults)
		uint8 None;
	UPROPERTY(EditAnywhere, Category = Defaults)
		uint8 One;
	UPROPERTY(EditAnywhere, Category = Defaults)
		uint8 Two;

};

And I get the following compilation error:

Error	1	error C2039: 'ByteProperty_0' : is not a member of 'FSTestStruct'	C:\Users\FrostSnake\Documents\Unreal Projects\WizardArena\Intermediate\Build\Win64\Inc\UProto\UProto.generated.cpp	435	1	WizardArena

and when I navigated to the error’s line, I found this:

UScriptStruct* Z_Construct_UScriptStruct_UMyStructs_FSTestStruct()
	{
		UStruct* Outer=Z_Construct_UClass_UMyStructs();
		static UScriptStruct* ReturnStruct = NULL;
		if (!ReturnStruct)
		{
			ReturnStruct = new(Outer, TEXT("STestStruct"), RF_Public|RF_Transient|RF_Native) UScriptStruct(FPostConstructInitializeProperties(), NULL, new UScriptStruct::TCppStructOps<FSTestStruct>, EStructFlags(0x00000001));
			UProperty* NewProp_Two = new(ReturnStruct, TEXT("Two"), RF_Public|RF_Transient|RF_Native) UByteProperty(CPP_PROPERTY_BASE(Two, FSTestStruct), 0x0000000000000001);
			UProperty* NewProp_One = new(ReturnStruct, TEXT("One"), RF_Public|RF_Transient|RF_Native) UByteProperty(CPP_PROPERTY_BASE(One, FSTestStruct), 0x0000000000000001);
			UProperty* NewProp_ByteProperty_0 = new(ReturnStruct, TEXT("ByteProperty_0"), RF_Public|RF_Transient|RF_Native) UByteProperty(CPP_PROPERTY_BASE(ByteProperty_0, FSTestStruct), 0x0000000000000001);
			ReturnStruct->StaticLink();
#if WITH_METADATA
			UMetaData* MetaData = ReturnStruct->GetOutermost()->GetMetaData();
			MetaData->SetValue(ReturnStruct, TEXT("BlueprintType"), TEXT("true"));
			MetaData->SetValue(ReturnStruct, TEXT("ModuleRelativePath"), TEXT("MyStructs.h"));
			MetaData->SetValue(NewProp_Two, TEXT("Category"), TEXT("Defaults"));
			MetaData->SetValue(NewProp_Two, TEXT("ModuleRelativePath"), TEXT("MyStructs.h"));
			MetaData->SetValue(NewProp_One, TEXT("Category"), TEXT("Defaults"));
			MetaData->SetValue(NewProp_One, TEXT("ModuleRelativePath"), TEXT("MyStructs.h"));
			MetaData->SetValue(NewProp_ByteProperty_0, TEXT("Category"), TEXT("Defaults"));
			MetaData->SetValue(NewProp_ByteProperty_0, TEXT("ModuleRelativePath"), TEXT("MyStructs.h"));
#endif
		}
		return ReturnStruct;
	}

As you can see, the property’s name (“None”) was changed to (“ByteProperty_0”).

Hi there! The name “None” is a reserved word that is used symbolically across UE4 to represent an uninitialized name. When the header parser is creating your field for you at header generation time, it enters StaticAllocateObject (in UOBjectGlobals.cpp) that then does this:

if(InName == NAME_None)
{
	InName = MakeUniqueObjectName( InOuter, InClass );
}

This should explain why you’re getting a default looking name rather than what you specified. I’d suggest using a different name, perhaps “Zero” in your example case?

Oh, okay thanks for clearing things out :smiley:

Since I was creating some sort of StatusEffect Struct, and I used None to indicate no status effect is applied.

Anyone im using NoStatusEffect instead of None, Thanks for your quick response :smiley: