SDL_DisplayFormat未在此范围内声明:使用SDL2

0X1*_*X1A 2 c++ sdl-2

编译器不返回丢失的SDL.h,而是SDL_DisplayFormat未在位于不同标头的类成员函数的范围内声明,即使我在main中初始化它.

SDL_Surface *SpriteLoad::Load(char *File)
{
    SDL_Surface *temp = NULL;
    SDL_Surface *opt = NULL;

    if ((temp = IMG_Load(File)) == NULL)
    {
        return NULL;
    }

    opt = SDL_DisplayFormat(temp);
    SDL_FreeSurface(temp);

    return opt;
}
Run Code Online (Sandbox Code Playgroud)

我主要通过类和成员函数进入SDL:

int main (int args, char *argc[])
{
    bool quit = false;

    OnRun Game;           // Class that init's SDL
    Window TestWin;

    GlobalTimer fps;
    TestWin.Debug();
Run Code Online (Sandbox Code Playgroud)

我可以使用该类使用SDL_Window创建一个窗口,也可以使用SDL_GetTick.

编辑:用于Sprite :: Load的标题目前是SDL,SDL_image,SDL_ttf和SDL_mixer,它们是从mercurial repo中提取和构建的.我不认为这是一个链接错误

gre*_*olf 11

您获得该编译器错误的原因是因为SDL_DisplayFormatSDL-2.0中不再存在该错误.

看后SDL维基DOC似乎SDL_DisplayFormat从SDL-1.2已经取代SDL_ConvertSurfaceFormat在SDL-2.0.