我正在尝试使用Visual Studio 2010创建SDL游戏,但是当我尝试构建项目时,我遇到了很多编译错误。我跟着this tutorial设置了Visual Studio,我正在关注this tutorial for SDL。给我这些错误的代码的两部分是我的CApp_OnEvent和CApp文件。
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 :(得分:0)
好吧,我再次回答了我自己的问题。我需要使用SDL_Event,而不是SDL_EVENT。
因为这样一个愚蠢的错误而感到羞耻