| 1 |
/* |
| 2 |
Copyright (C) 1997-2026 Sam Lantinga <[email protected]> |
| 3 |
|
| 4 |
This software is provided 'as-is', without any express or implied |
| 5 |
warranty. In no event will the authors be held liable for any damages |
| 6 |
arising from the use of this software. |
| 7 |
|
| 8 |
Permission is granted to anyone to use this software for any purpose, |
| 9 |
including commercial applications, and to alter it and redistribute it |
| 10 |
freely. |
| 11 |
*/ |
| 12 |
|
| 13 |
/* Test program to compare the compile-time version of SDL with the linked |
| 14 |
version of SDL |
| 15 |
*/ |
| 16 |
|
| 17 |
#include <stdio.h> |
| 18 |
#include <stdlib.h> |
| 19 |
|
| 20 |
#include "SDL.h" |
| 21 |
#include "SDL_revision.h" |
| 22 |
#include "SDL_test.h" |
| 23 |
|
| 24 |
int main(int argc, char *argv[]) |
| 25 |
{ |
| 26 |
SDL_version compiled; |
| 27 |
SDL_version linked; |
| 28 |
SDLTest_CommonState *state; |
| 29 |
|
| 30 |
state = SDLTest_CommonCreateState(argv, 0); |
| 31 |
if (!state) { |
| 32 |
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDLTest_CommonCreateState failed: %s\n", SDL_GetError()); |
| 33 |
return 1; |
| 34 |
} |
| 35 |
|
| 36 |
/* Enable standard application logging */ |
| 37 |
SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO); |
| 38 |
|
| 39 |
if (!SDLTest_CommonDefaultArgs(state, argc, argv)) { |
| 40 |
return 1; |
| 41 |
} |
| 42 |
|
| 43 |
if (!SDLTest_CommonInit(state)) { |
| 44 |
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s\n", SDL_GetError()); |
| 45 |
return 1; |
| 46 |
} |
| 47 |
|
| 48 |
#if SDL_VERSION_ATLEAST(2, 0, 0) |
| 49 |
SDL_Log("Compiled with SDL 2.0 or newer\n"); |
| 50 |
#else |
| 51 |
SDL_Log("Compiled with SDL older than 2.0\n"); |
| 52 |
#endif |
| 53 |
SDL_VERSION(&compiled); |
| 54 |
SDL_Log("Compiled version: %d.%d.%d (%s)\n", |
| 55 |
compiled.major, compiled.minor, compiled.patch, |
| 56 |
SDL_REVISION); |
| 57 |
SDL_GetVersion(&linked); |
| 58 |
SDL_Log("Linked version: %d.%d.%d (%s)\n", |
| 59 |
linked.major, linked.minor, linked.patch, |
| 60 |
SDL_GetRevision()); |
| 61 |
|
| 62 |
SDLTest_CommonQuit(state); |
| 63 |
return 0; |
| 64 |
} |