c++ - SDL_TTF header 给我带来麻烦

标签 c++ sdl header-files sdl-ttf

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

/* 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;
}

最佳答案

解决了问题。显然项目文件不知何故被破坏了,所以我只是将脚本转移到另一个项目并且一切正常。

关于c++ - SDL_TTF header 给我带来麻烦,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26436193/

相关文章:

C++预处理器#include

C++:转换/转换 void 指针到结构引用

c++ - 循环遍历两个不同长度的 vector 时的优化

C++-SDL : Blitting performance issues

c++ - Microsoft Visual Studio 2013 链接错误 1104

c++ - 预编译标准库头文件 - C++

c++ - 是否可以覆盖特定父级的虚拟函数?

c++ - 对 constexpr 函数有点困惑

c++ - SDL 僵硬运动

c++ - C/C++ 中的自给自足头文件