SDL_VERSION_ATLEAST
Name
SDL_VERSION_ATLEAST -- checks that the SDL header version is at least a certain minimum.
Synopsis
#include <SDL_version.h> #define SDL_VERSION_ATLEAST(X, Y, Z) (SDL_COMPILEDVERSION >= SDL_VERSIONNUM(X, Y, Z))
Description
This macro will evaluate to true if compiled with at least SDL version X.Y.Z.
Return Value
Returns 1 if the SDL version is greater than or equal to the specified version or 0 otherwise.
Note: This gives the version of the SDL headers that the program was compiled against, not the version of the linked libraries or any dynamically loaded libraries. Use SDL_GetVersion if you need the runtime library version.
Note: This macro could be used to support both SDL 1.2 and newer features of SDL 1.3 using preprocessor #if and #else statements.
Example
1 #include <SDL.h>
2 #include <stdio.h>
3
4 int main(int argc, char** argv) {
5 #if SDL_VERSION_ATLEAST(1, 3, 0)
6 if (SDL_Init(SDL_INIT_VIDEO|SDL_INIT_JOYSTICK|SDL_INIT_HAPTIC) != 0)
7 #else
8 if (SDL_Init(SDL_INIT_VIDEO|SDL_INIT_JOYSTICK) != 0)
9 #endif
10 {
11 fprintf(stderr, "Unable to initialize SDL: %s\n", SDL_GetError());
12 return 1;
13 }
14
15 /* ... */
16
17 SDL_Quit();
18 return 0;
19 }
