x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

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

Hey there,

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

asd ErrorPicture

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.

Product Version: Not Selected
Tags:
more ▼

asked Apr 06 '15 at 11:00 AM in Bug Reports

avatar image

eXi
6.8k 333 185 470

avatar image eXi Apr 06 '15 at 11:10 AM

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.

avatar image eXi Apr 06 '15 at 11:15 AM

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 ';'"

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

3 answers: sort voted first

Hi eXi,

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.

more ▼

answered Apr 16 '15 at 08:53 PM

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

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).

more ▼

answered Jun 24 '15 at 10:30 PM

avatar image

BunniPhD
136 4 68 15

avatar image Vormulac Feb 03 '16 at 09:09 PM

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

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

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.

more ▼

answered Jun 25 '15 at 10:00 AM

avatar image

tenowg
121 5 7 11

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question