[C++] USTRUCT gives missing ';' error

Hey there,

everytime i create a USTRUCT in one of my header files, i get this error:

http://puu.sh/h3qBr/fb8d060bc7.png

[ErrorPicture][2]

Here is my code:

#pragma once

#include "GameFramework/Actor.h"
#include "BaseRoomClass.generated.h"

namespace ERoomState
{
	enum Type
	{
		None,
		Normal,
		Corridor,
		Spawn,
		Boss,
	};
}

USTRUCT()
struct FRoomData
{
	GENERATED_USTRUCT_BODY()

	UPROPERTY(EditDefaultsOnly, Category = "Room Settings")
	FVector RoomSize;

	UPROPERTY(EditDefaultsOnly, Category = "Room Settings")
	ERoomState::Type RoomType;

	UPROPERTY(EditDefaultsOnly, Category = "Room Settings")
	TArray<FVector> DoorPositions;
};

UCLASS(BlueprintType, Blueprintable)
class SMALLCOOPTD_API ABaseRoomClass : public AActor
{
	GENERATED_BODY()
	
public:	

	UPROPERTY(EditDefaultsOnly, Category = "Room Config")
	FRoomData RoomConfig;

	FVector RoomCenter;

	FVector ExtendLeftBottom;
	FVector ExtendTopRight;

	// Sets default values for this actor's properties
	ABaseRoomClass();

	// Called when the game starts or when spawned
	virtual void BeginPlay() override;
	
	// Called every frame
	virtual void Tick( float DeltaSeconds ) override;

	
	
};

This is happening with every single USTRUCT and i am 100% sure that i don’t miss a “;”.

Sometimes it compiles and sometimes not. This is really annoying! The source seems to be the
“GENERATED_USTRUCT_BODY()”. As soon as i outcomment it, the error disappears (although without it i can’t compile the struct…)

I have other structs that work with the exact same setup. Where does this error come from? Is that my fault or is it a bug?

Engine Version: Newest launcher Download

I haven’t tested this in a new project, but i’m sure it will happen there too, since it is happening in a fresh and new class.

So, i just moved the ERoomState::Type to the normal body and it compiled. Then i moved it back to the USTRUCT, the error disappeared and it says it doesn’t know the Type. Which is normal since my custom namespace type is not a valid BP type i guess.

But all in all the ‘;’ disappeared. So it was never missing. The error is misleading and not really valid, since it disappeared with just moving some out of the struct and in again.

Added Ramas code for Enums (the normal code, but Ramas tutorial) and it still works. I was never missing the “;” ):

UENUM(BlueprintType)		//"BlueprintType" is essential to include
enum class ERoomType : uint8
{
	RT_None 		UMETA(DisplayName = "None"),
	RT_Normal 		UMETA(DisplayName = "None"),
	RT_Spawn 		UMETA(DisplayName = "None"),
	RT_Boss 		UMETA(DisplayName = "None"),
	RT_Corridor 	UMETA(DisplayName = "None")
};

USTRUCT(BlueprintType)
struct FRoomData
{
	GENERATED_USTRUCT_BODY()

	UPROPERTY(EditDefaultsOnly, Category = "Room Settings")
	FVector RoomSize;

	UPROPERTY(EditDefaultsOnly, Category = "Room Settings")
	ERoomType RoomType;

	UPROPERTY(EditDefaultsOnly, Category = "Room Settings")
	TArray<FVector> DoorPositions;
};

Maybe you can reproduce this error by creating the STRUCT like i did in the beginning and maybe find a better warning message then “missing ‘;’”

Hi ,

I have entered a feature request, UE-13932 to be considered by the development staff to clarify the UHT error present. The missing “;” is a quirk specific to intellisense.

Also, for those drawn to this via google. You can get a very similar error:

missing ;

On the end of the GENERATED_USTRUCT_BODY() line, if you fail to include the auto generated.h file in your class’s header file.
IE the #include "BaseRoomClass.generated.h" in the OP’s code (line 4).

The missing ; error is an intellisense error only, a false positive in most cases, ignore it, it will eventually catch up and remove the error, for me that is usually after compiling, sometimes it doesn’t go away until I reload VS…Sometimes it comes back… you will get alot of these “errors” as you work with UE and you projects get more complex.

Was struggling with this for the last hour. Spot on, thank you.