SDL_VERSION

Name

SDL_VERSION -- Macro to determine SDL version program was compiled against.

Synopsis

#include <SDL_version.h>

#define SDL_VERSION(x)                          \
{                                   \
    (x)->major = SDL_MAJOR_VERSION;                 \
    (x)->minor = SDL_MINOR_VERSION;                 \
    (x)->patch = SDL_PATCHLEVEL;                    \
}

Description

This macro fills in a SDL_version structure with the version of the library you compiled against. This is determined by what header the compiler uses. Note that if you dynamically linked the library, you might have a slightly newer or older version at runtime. That version can be determined with SDL_GetVersion(), which, unlike SDL_VERSION, is not a macro.

Parameters

x

A pointer to a SDL_version struct to initialize.

Return Value

Returns nothing.

Example

   1 #include <SDL.h>
   2 #include <stdio.h>
   3 
   4 int cmpver(SDL_version* ver1, SDL_version* ver2) {
   5     if (ver1->major == ver2->major && ver1->minor == ver2->minor && ver1->patch == ver2->patch)
   6         return 0;
   7     if (ver1->major > ver2->major ||
   8         ver1->major == ver2->major && ver1->minor > ver2->minor ||
   9         ver1->major == ver2->major && ver1->minor == ver2->minor && ver1->patch > ver2->patch)
  10         return 1;
  11     return -1;
  12 }
  13 
  14 int main(int argc, char** argv) {
  15     SDL_version version_compiled, version_linked;
  16 
  17     /* ... */
  18 
  19     SDL_VERSION(&version_compiled);
  20     SDL_GetVersion(&version_linked);
  21     switch (cmpver(version_compiled, version_linked) {
  22         case 1:
  23             fprintf(stderr, "SDL version too low.  Aborting...\n");
  24             return 1;
  25         case -1:
  26             fprintf(stderr, "SDL version mismatch.  Continuing anyway...\n");
  27             break;
  28     }
  29 
  30     /* ... */
  31 
  32     return 0;
  33 }

See Also

SDL_version, SDL_GetVersion


CategorySDL13API CategorySDL13APIVersion

SDL-1.3/SDL_VERSION (last edited 2009-02-14 02:01:20 by KenBull)