尝试将游戏移植到 Linux,调用 XInitThreads 时出现语法错误
Trying to port a game to Linux, calling XInitThreads gets me a syntax error
下面是代码中违规行的样子:
#ifdef SFML_SYSTEM_LINUX
XInitThreads();
#endif
我在代码开头调用了必要的库,如下所示:
#ifdef SFML_SYSTEM_LINUX
#include <X11/Xlib.h>;
#include <unistd.h>
#include <pwd.h>
#include <iostream>
#include <stdlib.h>
#endif
它在 Code::Blocks 中给我这个错误:
error: expected constructor, destructor, or type conversion before ‘;’ token
此错误引用代码中的第 111 行,这是我上面引用的第一个函数中的 XInitThreads 调用。
我错过了什么吗?我已尝试将链接器设置为包含 X11 库,但到目前为止它没有任何改变。
编辑:这是 game.cpp 开头的更多代码 - http://pastebin.com/7D2WLRM7
您似乎正试图 "call" 在任何函数或方法块之外执行此函数。
您的编译器无法理解您要执行的操作。也许将这些行移动到 Game::Init?
下面是代码中违规行的样子:
#ifdef SFML_SYSTEM_LINUX
XInitThreads();
#endif
我在代码开头调用了必要的库,如下所示:
#ifdef SFML_SYSTEM_LINUX
#include <X11/Xlib.h>;
#include <unistd.h>
#include <pwd.h>
#include <iostream>
#include <stdlib.h>
#endif
它在 Code::Blocks 中给我这个错误:
error: expected constructor, destructor, or type conversion before ‘;’ token
此错误引用代码中的第 111 行,这是我上面引用的第一个函数中的 XInitThreads 调用。
我错过了什么吗?我已尝试将链接器设置为包含 X11 库,但到目前为止它没有任何改变。
编辑:这是 game.cpp 开头的更多代码 - http://pastebin.com/7D2WLRM7
您似乎正试图 "call" 在任何函数或方法块之外执行此函数。
您的编译器无法理解您要执行的操作。也许将这些行移动到 Game::Init?