【发布时间】:2012-02-02 05:26:06
【问题描述】:
所以,我对 C++ 编程还很陌生,但我已经在 python 和 FreeBASIC 中广泛使用了 SDL。我确定我在这里遗漏了一些愚蠢的东西,但无论我尝试什么,我都会在我的 video.h 文件中收到错误“错误:'namespace'之前的预期初始化程序”。这让我有点发疯。
#include "SDL/SDL.h"
#include <iostream>
namespace video {
// This is here because like video, everything uses it and the players should never be able to touch it.
int rolldice(int minimumroll, int maximumroll, int numberofdice);
// Same Here.
char* charraystring(std::string prestring);
// Now we're in video proper
// This function loads an image, checks to make sure it works, returns the image, and unloads the testing surface.
SDL_Surface* loadimage(std::string path);
// This is an optimized blitter that will exit with a signal if it encounters an error.
void oblit(SDL_Surface* pic, SDL_Rect frame, SDL_Surface* screen, SDL_Rect location);
}
【问题讨论】:
-
第 4 行。实际的错误消息是 /home/dyngar/Workspace/C/CLAIR/video.h:4:1: error: expected initializer before 'namespace' 抱歉,我从文件的旧版本。
-
你确定这是你的整个文件吗?该错误中的行号不匹配
-
抱歉,我从文件的早期版本中粘贴了错误消息。它实际上在第 4 行。该死的,你们很快。提前致谢。
-
您能否发布包含 video.h 的文件的开头以及编译器的完整输出?
-
如果你通过预处理器运行你的源文件(例如
gcc -I /usr/include -I /usr/include/c++/* -E source.cc),“namespace video {”之前的行是什么?
标签: c++ sdl initializer