Visual Studio 2010 SDL_Event errors

Visual Studio 2010 SDL_Event errors

本文关键字:Event errors SDL Studio 2010 Visual      更新时间:2023-10-16

我正试图用Visual Studio 2010创建一个SDL游戏,但在构建项目时遇到了很多编译错误。我遵循了本教程来设置Visual Studio,并且我遵循了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 "DebugSDL Game.unsuccessfulbuild".
1>ClCompile:
1>  CApp_OnRender.cpp
1>c:usersnathandocumentsvisual studio 2010projectssdl gamesdl gamecapp.h(18): error C2061: syntax error : identifier 'SDL_EVENT'
1>  CApp_OnLoop.cpp
1>c:usersnathandocumentsvisual studio 2010projectssdl gamesdl gamecapp.h(18): error C2061: syntax error : identifier 'SDL_EVENT'
1>  CApp_OnInit.cpp
1>c:usersnathandocumentsvisual studio 2010projectssdl gamesdl gamecapp.h(18): error C2061: syntax error : identifier 'SDL_EVENT'
1>  CApp_OnEvent.cpp
1>c:usersnathandocumentsvisual studio 2010projectssdl gamesdl gamecapp.h(18): error C2061: syntax error : identifier 'SDL_EVENT'
1>c:usersnathandocumentsvisual studio 2010projectssdl gamesdl gamecapp_onevent.cpp(3): error C2065: 'SDL_EVENT' : undeclared identifier
1>c:usersnathandocumentsvisual studio 2010projectssdl gamesdl gamecapp_onevent.cpp(3): error C2065: 'Event' : undeclared identifier
1>c:usersnathandocumentsvisual studio 2010projectssdl gamesdl gamecapp_onevent.cpp(3): error C2448: 'CApp::OnEvent' : function-style initializer appears to be a function definition
1>  CApp_OnCleanup.cpp
1>c:usersnathandocumentsvisual studio 2010projectssdl gamesdl gamecapp.h(18): error C2061: syntax error : identifier 'SDL_EVENT'
1>  CApp.cpp
1>c:usersnathandocumentsvisual studio 2010projectssdl gamesdl gamecapp.h(18): error C2061: syntax error : identifier 'SDL_EVENT'
1>c:usersnathandocumentsvisual studio 2010projectssdl gamesdl gamecapp.cpp(12): error C2065: 'SDL_EVENT' : undeclared identifier
1>c:usersnathandocumentsvisual studio 2010projectssdl gamesdl gamecapp.cpp(12): error C2146: syntax error : missing ';' before identifier 'Event'
1>c:usersnathandocumentsvisual studio 2010projectssdl gamesdl gamecapp.cpp(12): error C2065: 'Event' : undeclared identifier
1>c:usersnathandocumentsvisual studio 2010projectssdl gamesdl gamecapp.cpp(15): error C2065: 'Event' : undeclared identifier
1>c:usersnathandocumentsvisual studio 2010projectssdl gamesdl gamecapp.cpp(15): error C3861: 'SDL_PollEvent': identifier not found
1>c:usersnathandocumentsvisual studio 2010projectssdl gamesdl gamecapp.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

你知道我为什么会犯这些错误吗?谢谢

好吧,我又回答了我自己的问题。我需要使用SDL_Event,而不是SDL_Event。

为这样一个愚蠢的错误羞愧地垂下头