C:\CPPProject\GameEngine.h|4|error: expected '=', ',', ';', 'asm' or '__attribute__' before 'GameEngine'|

Started by
0 comments, last by brx 11 years, 7 months ago
For some reason when i try to compile my code I get the error message:

C:\CPPProject\GameEngine.h|4|error: expected '=', ',', ';', 'asm' or '__attribute__' before 'GameEngine'|
[/quote]
I have setup my compiler and linker settings correctly.

Compiler & Debugger Settings ->Linker Settings->Other Linker Settings: -lmingw32 -lSDLmain -lSDL

Compiler & Debugger Settings ->Search Directory->Compiler: C:\CodeBlocks\SDL\include

Compiler & Debugger Settings ->Search Directory->Linker: C:\CodeBlocks\SDL\lib

I am using CodeBlocks 10.05 and installed SDL via the DevPaks installer. .Any assistance would be greatly appreciated.

Sincerely,

Registered User
Advertisement
The GameEngine.h file is compiled as C code because of the main.c file which includes it. Try renaming that file to main.cpp. Also you should put header guards in the GameEngine.h file:

#ifndef GAMEENGINE_H
#define GAMEENGINE_H
// include required libraries
#include <SDL.h>
class GameEngine
{
private:
// screen display surface
// SDL_Surface* Screen;
public:
bool init();
void run();
};
#endif


or


#pragma once
// include required libraries
#include <SDL.h>
class GameEngine
{
private:
// screen display surface
// SDL_Surface* Screen;
public:
bool init();
void run();
};

This topic is closed to new replies.

Advertisement