C++ SDL头文件错误
我正在遵循一个教程,它说在某一时刻它应该编译,但它出错了。
然而,为了找出为什么我只是使用他们的代码而不是我的代码并将他们的所有代码粘贴进去,这会出现错误。它位于头文件中,我已将错误放在代码“
#ifndef _CApp_H_
#define _CApp_H_
#include <SDL.h>
class CApp {
private:
bool Running;
public:
CApp();
int OnExecute();
public:
bool OnInit();
void OnEvent(SDL_Event* Event);
void OnLoop();
void OnRender();
void OnCleanup();
};
#endif
Errors:
Syntax error before CAPP”(第 6 行)下面。 第 6 行第一个 { 之前的语法错误。 之前的语法错误:第 14 行。 第 25 行 } 之前的
所有文件均已声明。我也有另一个错误,在这里:
#include "CApp.h"
void CApp::OnCleanup() {
}
之前:。除了第 3 行之外,它没有提供更多描述。
I'm following a tutorial and it said at one point it should compile, but it errored.
To find out why I just used their code instead of mine and have just pasted all theirs in, however, this is picking up errors. It's in a header file, I've placed the errors below the code
#ifndef _CApp_H_
#define _CApp_H_
#include <SDL.h>
class CApp {
private:
bool Running;
public:
CApp();
int OnExecute();
public:
bool OnInit();
void OnEvent(SDL_Event* Event);
void OnLoop();
void OnRender();
void OnCleanup();
};
#endif
Errors:
Syntax error before CAPP, on line 6.
Syntax error before the first {, on line 6.
Syntax error before : on line 14.
Line 25 before }
All files are declared. I have another error, too, here:
#include "CApp.h"
void CApp::OnCleanup() {
}
Before :. it doesn't give more description than that apart from it's on line 3.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
SDL.h 文件是否在您的包含路径中?这个例子中的任何内容都没有让我觉得错误。
Is the SDL.h file in your include path? Nothing in the example jumps out at me as wrong.
这并不是您问题的正确答案,但是...
我强烈建议切换到 SFML 而不是 SDL。它本质上是一个用 C++ 编写的现代化的、面向对象的 SFML。与 SDL 相比,它具有许多优点(例如完全硬件加速的 2D 绘图)。如果您愿意,请检查一下。
This isn't really a proper answer to your question, but...
I would highly recommend switching to SFML instead of SDL. It's essentially a modernized, object-oriented SFML written in C++. It has many advantages over SDL (such as fully hardware-accelerated 2D drawing). Check it out if you'd like.
它可能位于路径中。尝试输入#include“SDL\SDL.h”。
It's probably located in a path. Try putting # include "SDL\SDL.h".