test/testver.c
author Sam Lantinga <slouken@libsdl.org>
Wed, 16 Feb 2011 02:37:09 -0800
changeset 5310 a9945ce48999
parent 4419 5e7e1f1a4056
child 5359 d5fe4ed3a28d
permissions -rw-r--r--
Made it possible to build SDL from a fresh checkout without any additional steps.

The trick is that if you're using configure and you don't want to have SDL_config.h and SDL_revision.h to show up as modified, you need to configure and build from a separate directory.

You also need to include SDL_revision.h directly if you want to use the SDL_REVISION constant, as a side effect of these changes.
     1 
     2 /* Test program to compare the compile-time version of SDL with the linked
     3    version of SDL
     4 */
     5 
     6 #include <stdio.h>
     7 #include <stdlib.h>
     8 
     9 #include "SDL.h"
    10 #include "SDL_revision.h"
    11 
    12 int
    13 main(int argc, char *argv[])
    14 {
    15     SDL_version compiled;
    16     SDL_version linked;
    17 
    18 #if SDL_VERSION_ATLEAST(1, 3, 0)
    19     printf("Compiled with SDL 1.3 or newer\n");
    20 #else
    21     printf("Compiled with SDL older than 1.3\n");
    22 #endif
    23     SDL_VERSION(&compiled);
    24     printf("Compiled version: %d.%d.%d (%s)\n",
    25            compiled.major, compiled.minor, compiled.patch, SDL_REVISION);
    26     SDL_GetVersion(&linked);
    27     printf("Linked version: %d.%d.%d (%s)\n",
    28            linked.major, linked.minor, linked.patch, SDL_GetRevision());
    29     SDL_Quit();
    30     return (0);
    31 }