【问题标题】:Compiler expecting a version of function which "isn't there"编译器期望“不存在”的函数版本
【发布时间】:2015-09-10 01:46:11
【问题描述】:

我正在尝试在 Windows 上将 SDL-gfx 与 SDL2 一起使用来绘制一个圆圈,但收到一条(对我来说)很难弄清楚的错误消息

我收到错误消息:

无法将参数 '1' 的 'SDL_Renderer*' 转换为 'SDL_Surface*' 到 'int circleColor(SDL_Surface*, Sint16, Sint16, Sint16, Uint32)*

我看到的唯一功能就是这个

SDL2_GFXPRIMITIVES_SCOPE int circleColor(SDL_Renderer * renderer, Sint16 x, Sint16 y, Sint16 rad, Uint32 color);

但是错误信息似乎是说函数有这些参数

circleColor(SDL_Surface*, Sint16, Sint16, Sint16, Uint32)

我找不到任何这样的功能。据我所知,我的计算机上不存在此版本的功能(尽管显然我错了)。怎么会这样?

谢谢

【问题讨论】:

  • 当我用谷歌搜索时,我发现SDL_gfxPrimitives.h 确实存在circleColor(SDL_Surface *,...。也许你两个都有?
  • 您正在尝试针对 SDL2 标头编译 SDL1 代码。由于 API 不兼容,因此无法正常工作。
  • 感谢您的洞察力。如果我从 SDL_gfx 注释该函数,SDL2 将起作用。我从 SDL_gfx 包含的头文件是 SDL2_gfxPrimitives.h,它也不是来自 SDL1。错误消息是否让您知道程序的哪个部分正在使用 SDL1?

标签: c++ sdl


【解决方案1】:

SDL2-gfx 有 SDL2_gfxPrimitives.h,您可以在其中找到此声明:

int circleColor(SDL_Renderer * 渲染器, Sint16 x, Sint16 y, Sint16 rad, Uint32 颜色);

而旧的 SDL-gfx 有 SDL_gfxPrimitives.h,其中包含:

int circleColor(SDL_Surface * 表面, Sint16 x, Sint16 y,Sint16 r, Uint32 颜色);

您的计算机上可能有两个版本,或者您混淆了标题。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-04-05
    • 2016-08-31
    • 1970-01-01
    • 2018-06-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多