J'ai commencé à faire du jeu pour mon projet d'école en C++ avec la bibliothèque SDL. Mais je ne peux pas trouver ce que je fais mal dans le code ci-dessous.Problèmes d'inclusion SDL/C++
J'utilise VC++ 2008,
ici est la sortie compilator:
1>Compiling...
1>initGame.cpp
1>.\dec.h(4) : error C2065: 'SDL_HWSURFACE' : undeclared identifier
1>.\dec.h(4) : error C2065: 'SDL_DOUBLEBUF' : undeclared identifier
1>.\dec.h(6) : error C2143: syntax error : missing ';' before '*'
1>.\dec.h(6) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>.\dec.h(6) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>.\dec.h(6) : error C2065: 'NULL' : undeclared identifier
1>.\initgame.cpp(4) : error C2065: 'SDL_INIT_VIDEO' : undeclared identifier
1>.\initgame.cpp(4) : error C2065: 'SDL_INIT_AUDIO' : undeclared identifier
1>.\initgame.cpp(4) : error C2065: 'SDL_INIT_TIMER' : undeclared identifier
1>.\initgame.cpp(4) : error C3861: 'SDL_Init': identifier not found
1>.\initgame.cpp(5) : error C2065: 'cerr' : undeclared identifier
1>.\initgame.cpp(5) : error C2065: 'endl' : undeclared identifier
1>.\initgame.cpp(9) : error C3861: 'SDL_SetVideoMode': identifier not found
Et voici la source
dec.h:
#ifndef DEC_H
#define DEC_H
int g_win_flags = SDL_HWSURFACE|SDL_DOUBLEBUF;
SDL_Surface *g_screen = NULL;
#endif
initGame.cpp :
#include "dec.h"
bool initGame(){
if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_TIMER) == -1){
cerr << "Unable to initialize SDL" << endl;
return false;
}
g_screen = SDL_SetVideoMode(640, 480, 0, g_win_flags);
return true;
}
main.cpp:
#include <iostream>
#include <SDL.h>
#pragma comment(lib, "SDL.lib")
#pragma comment(lib, "SDLmain.lib")
using namespace std;
#include "initGame.cpp"
int main(int argc, char *argv[]){
initGame();
return 0;
}
Je serais très reconnaissant si quelqu'un pouvait me aider.
Merci d'une avance ont une belle journée :)
@Zod - défaisait votre rebouclage,. C'est un problème C++. Le problème n'est pas spécifique à Visual C++. –
Oh mon dieu, il y a tellement de petites choses dans ce code qui me soulèvent des avertissements. Certains pourraient appeler le style de code si. –