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.
slouken@0
     1
slouken@0
     2
/* Test program to compare the compile-time version of SDL with the linked
slouken@0
     3
   version of SDL
slouken@0
     4
*/
slouken@0
     5
slouken@0
     6
#include <stdio.h>
icculus@1154
     7
#include <stdlib.h>
slouken@0
     8
slouken@0
     9
#include "SDL.h"
slouken@5310
    10
#include "SDL_revision.h"
slouken@0
    11
slouken@1895
    12
int
slouken@1895
    13
main(int argc, char *argv[])
slouken@0
    14
{
slouken@1895
    15
    SDL_version compiled;
slouken@2983
    16
    SDL_version linked;
slouken@0
    17
slouken@2983
    18
#if SDL_VERSION_ATLEAST(1, 3, 0)
slouken@2983
    19
    printf("Compiled with SDL 1.3 or newer\n");
slouken@0
    20
#else
slouken@2983
    21
    printf("Compiled with SDL older than 1.3\n");
slouken@0
    22
#endif
slouken@1895
    23
    SDL_VERSION(&compiled);
icculus@4419
    24
    printf("Compiled version: %d.%d.%d (%s)\n",
slouken@2983
    25
           compiled.major, compiled.minor, compiled.patch, SDL_REVISION);
slouken@2983
    26
    SDL_GetVersion(&linked);
icculus@4419
    27
    printf("Linked version: %d.%d.%d (%s)\n",
slouken@2983
    28
           linked.major, linked.minor, linked.patch, SDL_GetRevision());
slouken@1895
    29
    SDL_Quit();
slouken@1895
    30
    return (0);
slouken@0
    31
}