What does this error mean?

#pragma once

#include "CoreMinimal.h"
#include "Console/Cartridge.h"
#include "BullCowCartridge.generated.h"
#include <string>



UCLASS(ClassGroup=(Custom), meta=(BlueprintSpawnableComponent))
class BULLCOWGAME_API UBullCowCartridge : public UCartridge
{
	GENERATED_BODY()

	public:
	virtual void BeginPlay() override;
	virtual void OnInput(const FString& Input) override;

	// Your declarations go below!
	private:
	FString HiddenWord;
};

GENERATED_BODY() has a squiggly line, and the error says
“this declaration has no storage class or type specifierC/C++(77)”

Here’s the main code.

#include "BullCowCartridge.h"
#include <string>

 void UBullCowCartridge::BeginPlay() // When the game starts
{
    Super::BeginPlay();
    PrintLine(TEXT("Hello There!!!"));
    PrintLine(TEXT("Welcome to the BullCow Game."));
    PrintLine(TEXT("Guess an 10 letter Isogram."));
    PrintLine(TEXT("Type Your answer and Press Enter."));
    FString HiddenWord = TEXT("Journalist");
}

void UBullCowCartridge::OnInput(const FString& Input) // When the player hits enter
{     

    if(Input==HiddenWord)
    {
        PrintLine(TEXT("You Win"));
    }
    else
    {
        PrintLine(TEXT("You Lose"));
    }
}

Edit: I figured it out, it seems headers shouldn’t be used after the .h headers(whatever they are). I changed the code. Error: #include found after .generated.h file

#include <string>
#include "CoreMinimal.h"
#include "Console/Cartridge.h"
#include "BullCowCartridge.generated.h"

The generated header should always be the last include. Also <string> is for std::string which you aren’t using.

1 Like

So header is not necessary. Okay. But what does it mean by generated header?

That Unreal generates it; they all have .generated. in the name. The generated.h header must be the last include.

1 Like

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.

Privacy & Terms