Struct Error C2144 'float' should be preceded by ';'

Do you get these errors during compilation or runtime? I just copy-pasted your code into sample project and it compiles fine.

One thing I can think of is that you keep this struct alone in header file. I mean you only have this struct in header file. If thats true then try putting this struct into header file of other class (with UObject or AActor) or try adding dummy class at the bottom of your ARGPlayerBaseAttributes.h file like so:

UCLASS()
class UDummyClass : public UObject
{
GENERATED_UCLASS_BODY()
};

For more detailed info check out this topic Header-only USTRUCT referenced in module's PrivatePCH not detected by UBT - Programming & Scripting - Unreal Engine Forums

Hope it helps

Howdy all,

I am trying to create a struct which is used by a few of my classes.

Below is the entire ARGPlayerBaseAttributes.h file

I have the following code and am getting the following error:

#pragma once

USTRUCT()
struct FARGPlayerBaseAttributes
{
	GENERATED_USTRUCT_BODY()

	UPROPERTY()
	float Strength;

	UPROPERTY()
	float Dexterity;

	UPROPERTY()
	float Inteligence;

	UPROPERTY()
	float Charisma;

	UPROPERTY()
	float Wisdom;

	UPROPERTY()
	float Constitution;

	//Set
	void SetStrength(const float NewValue)
	{
		Strength = NewValue;
	}

	void SetDexterity(const float NewValue)
	{
		Dexterity = NewValue;
	}

	void SetInteligence(const float NewValue)
	{
		Inteligence = NewValue;
	}

	void SetCharisma(const float NewValue)
	{
		Charisma = NewValue;
	}

	void SetWisdom(const float NewValue)
	{
		Wisdom = NewValue;
	}

	void SetConstitution(const float NewValue)
	{
		Constitution = NewValue;
	}

	FARGPlayerBaseAttributes()
	{
		Strength = 0.0f;
		Dexterity = 0.0f;
		Inteligence = 0.0f;
		Charisma = 0.0f;
		Wisdom = 0.0f;
		Constitution = 0.0f;
	}
};

Error: ARGPlayerBaseAttributes.h(9): error C2144: syntax error : ‘float’ should be preceded by ‘;’

Error: ARGPlayerBaseAttributes.h(9): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int

Am I doing something very n00bish?

Cheers

This is at compile time.

Adding in a dummy class seems to have fixed the issue :slight_smile:

Thanks

This may not work as of 4.11 or 4.12

The file you are in at the moment does not know unreal macros (GENERATED_USTRUCT_BODY, USTRUCT, UPORPERTY, etc).

Solution 1: Remove all Unreal Macros.

Solution 2: Include something to know the Unreal Macros. (Some suggest creating a dummy class, which will cause the import of all the default things, or generated header files)