2011-11-24 183 views
0

我试图用Visual Studio 2010创建一个SDL游戏,但是当我尝试构建项目时遇到了很多编译错误。我跟着this tutorial设置了Visual Studio,我正在关注this tutorial for SDL。给我这些错误的代码的两个部分是我的CApp_OnEvent和CApp文件。Visual Studio 2010 SDL_Event错误

CApp_OnEvent:

#include "CApp.h" 

void CApp::OnEvent(SDL_EVENT* Event) { 
} 

CAPP:

#include "CApp.h" 

CApp::CApp() { 
Running = true; 
} 

int CApp::OnExecute() { 
if(OnInit() == false) { 
    return -1; 
} 

SDL_EVENT Event; 

while(Running) { 
    while(SDL_PollEvent(&Event)) { 
     OnEvent(&Event); 
    } 

    OnLoop(); 
    OnRender(); 
} 

OnCleanup(); 

return 0; 
} 

int main(int argc, char* argv[]) { 
CApp theApp; 

return theApp.OnExecute(); 
} 

这里是Visual Studio中的输出,当我尝试建立它:

1>------ Build started: Project: SDL Game, Configuration: Debug Win32 ------ 
1>Build started 11/24/2011 10:58:45 AM. 
1>InitializeBuildStatus: 
1> Touching "Debug\SDL Game.unsuccessfulbuild". 
1>ClCompile: 
1> CApp_OnRender.cpp 
1>c:\users\nathan\documents\visual studio 2010\projects\sdl game\sdl game\capp.h(18): error C2061: syntax error : identifier 'SDL_EVENT' 
1> CApp_OnLoop.cpp 
1>c:\users\nathan\documents\visual studio 2010\projects\sdl game\sdl game\capp.h(18): error C2061: syntax error : identifier 'SDL_EVENT' 
1> CApp_OnInit.cpp 
1>c:\users\nathan\documents\visual studio 2010\projects\sdl game\sdl game\capp.h(18): error C2061: syntax error : identifier 'SDL_EVENT' 
1> CApp_OnEvent.cpp 
1>c:\users\nathan\documents\visual studio 2010\projects\sdl game\sdl game\capp.h(18): error C2061: syntax error : identifier 'SDL_EVENT' 
1>c:\users\nathan\documents\visual studio 2010\projects\sdl game\sdl game\capp_onevent.cpp(3): error C2065: 'SDL_EVENT' : undeclared identifier 
1>c:\users\nathan\documents\visual studio 2010\projects\sdl game\sdl game\capp_onevent.cpp(3): error C2065: 'Event' : undeclared identifier 
1>c:\users\nathan\documents\visual studio 2010\projects\sdl game\sdl game\capp_onevent.cpp(3): error C2448: 'CApp::OnEvent' : function-style initializer appears to be a function definition 
1> CApp_OnCleanup.cpp 
1>c:\users\nathan\documents\visual studio 2010\projects\sdl game\sdl game\capp.h(18): error C2061: syntax error : identifier 'SDL_EVENT' 
1> CApp.cpp 
1>c:\users\nathan\documents\visual studio 2010\projects\sdl game\sdl game\capp.h(18): error C2061: syntax error : identifier 'SDL_EVENT' 
1>c:\users\nathan\documents\visual studio 2010\projects\sdl game\sdl game\capp.cpp(12): error C2065: 'SDL_EVENT' : undeclared identifier 
1>c:\users\nathan\documents\visual studio 2010\projects\sdl game\sdl game\capp.cpp(12): error C2146: syntax error : missing ';' before identifier 'Event' 
1>c:\users\nathan\documents\visual studio 2010\projects\sdl game\sdl game\capp.cpp(12): error C2065: 'Event' : undeclared identifier 
1>c:\users\nathan\documents\visual studio 2010\projects\sdl game\sdl game\capp.cpp(15): error C2065: 'Event' : undeclared identifier 
1>c:\users\nathan\documents\visual studio 2010\projects\sdl game\sdl game\capp.cpp(15): error C3861: 'SDL_PollEvent': identifier not found 
1>c:\users\nathan\documents\visual studio 2010\projects\sdl game\sdl game\capp.cpp(16): error C2065: 'Event' : undeclared identifier 
1> Generating Code... 
1> 
1>Build FAILED. 
1> 
1>Time Elapsed 00:00:00.24 
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ========== 

您可以查看我的项目的其余部分代码去这里: http://www.mediafire.com/download.php?5524qr1zodracc5

为什么我得到这些错误的任何想法?谢谢!

+0

可以打开SDL.h在你的项目?可能你忘了在项目属性中添加额外的包含目录。 – shadeglare

回答

0

那么,我已经回答了我自己的问题。我需要使用SDL_Event,而不是SDL_EVENT。

挂在耻辱头这种低级错误