1

在病毒迫使我重置为出厂状态后,我一直试图在我的计算机上设置 SDL。使用我的 IDE CodeBlocks 运行 SDL 很容易,但设置扩展库却不那么容易。CodeBlocks 识别库的存在,但在 SDL_ttf 标头和 SDL_image 标头中给了我多个错误。给我带来麻烦的代码部分是这样的:

/* Set up for C function definitions, even when using C++ */
#ifdef __cplusplus
extern "C" {
#endif

第一行生成错误“error: expected unqualified-id before string constant”,第三行生成上述错误和错误“error: expected '}' before end of line”。我的猜测是,这可能与用 C 编写的 SDL 有关,也许我的 CodeBlocks 尚未配置为识别 C。

编辑:测试源代码是这样的:

SDL_Surface* imageBlitingFunctions::loadText(Uint8 red, Uint8 blue, Uint8 green, std::string fontname, int fontSize, std::string text)
{

    SDL_Color textColor = {red, blue, green};

    TTF_Font *font1 = TTF_OpenFont(fontname.c_str(), fontSize);

    SDL_Surface *message1 = TTF_RenderText_Solid(font1, text.c_str(), textColor);

    return message1;
}
4

1 回答 1

0

想通了问题。显然项目文件不知何故损坏了,所以我只是将脚本转移到另一个项目,一切正常。

于 2014-10-22T18:03:24.897 回答