0

I plan to use both SDL_GetKeyboardState and SDL_Overlay but it seems there is a conflict.

#include <stdio.h>
#include <SDL/SDL.h>
#include <SDL2/SDL.h>

int main()
{
    const Uint8 *keystate = SDL_GetKeyboardState(NULL);
    SDL_Overlay *bmp;
    printf("hello world!");
}

Compile:

gcc -c main.cpp

When order of headers are:

#include <SDL/SDL.h>
#include <SDL2/SDL.h>

error: ‘SDL_GetKeyboardState’ was not declared in this scope
 const Uint8 *keystate = SDL_GetKeyboardState(NULL);
                                                  ^

or

#include <SDL2/SDL.h>
#include <SDL/SDL.h>

error: ‘SDL_Overlay’ was not declared in this scope
     SDL_Overlay *bmp;
     ^

Even adding

#include <SDL2/SDL_video.h>

does not solve the problem.

What header should I add to use SDL_Overlay?

ar2015
  • 5,558
  • 8
  • 53
  • 110
  • 3
    You cannot combine both SDL 1.2 and SDL2. You can use [SDL_GetKeyState](https://www.libsdl.org/release/SDL-1.2.15/docs/html/sdlgetkeystate.html) with SDL 1.2 instead. There are no overlays in SDL2 but look at https://stackoverflow.com/questions/17579286/sdl2-0-alternative-for-sdl-overlay – keltar Nov 20 '17 at 12:18
  • @keltar, Many thanks. – ar2015 Nov 20 '17 at 13:16

0 Answers0