I’m using g++ compiler with c++ 17 standard on Debian 9 to write an game engine. I have two simple objects which functionality is divided in to two files: game.cpp
and render.cpp
. I include SDL2 library in both of them, also game.cpp is including render.h which is using render.cpp
.
The code is working separate from SDL but seems I mess up something with including order. The compiler gives me two errors:
In file included from /usr/include/SDL2/SDL_config.h:33:0,
from /usr/include/SDL2/SDL_stdinc.h:31,
from /usr/include/SDL2/SDL_main.h:25,
from /usr/include/SDL2/SDL.h:32,
from ../src/render.cpp:4:
/usr/include/SDL2/SDL_platform.h:169:1: error: expected ‘,’ or ‘;’ before ‘extern’
extern "C" {
^~~~~~
In file included from /usr/include/SDL2/SDL_config.h:33:0,
from /usr/include/SDL2/SDL_stdinc.h:31,
from /usr/include/SDL2/SDL_main.h:25,
from /usr/include/SDL2/SDL.h:32,
from ../src/game.cpp:5:
/usr/include/SDL2/SDL_platform.h:169:1: error: expected ‘,’ or ‘;’ before ‘extern’
extern "C" {
^~~~~~
Line 4 and 5 is simply #include "SDL2/SDL.h"
.