Atlas - testver.c
Home / ext / SDL / test Lines: 1 | Size: 1663 bytes [Download] [Show on GitHub] [Search similar files] [Raw] [Raw (proxy)][FILE BEGIN]1/* 2 Copyright (C) 1997-2025 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#include <SDL3/SDL.h> 17#include <SDL3/SDL_main.h> 18#include <SDL3/SDL_revision.h> 19 20int main(int argc, char *argv[]) 21{ 22 if (argc > 1) { 23 SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "USAGE: %s", argv[0]); 24 return 1; 25 } 26 27#if SDL_VERSION_ATLEAST(3, 0, 0) 28 SDL_Log("Compiled with SDL 3.0 or newer"); 29#else 30 SDL_Log("Compiled with SDL older than 3.0"); 31#endif 32 SDL_Log("Compiled version: %d.%d.%d (%s)", 33 SDL_MAJOR_VERSION, SDL_MINOR_VERSION, SDL_MICRO_VERSION, 34 SDL_REVISION); 35 int version = SDL_GetVersion(); 36 const char *revision = SDL_GetRevision(); 37 SDL_Log("Runtime version: %d.%d.%d (%s)", 38 SDL_VERSIONNUM_MAJOR(version), SDL_VERSIONNUM_MINOR(version), SDL_VERSIONNUM_MICRO(version), 39 revision); 40 /* This is not an API guarantee, but we try to make sure it's true, 41 * so that the version number can be extracted while debugging with: 42 * strings libSDL3.so.0 | grep SDL- 43 */ 44 if (SDL_strncmp(revision, "SDL-", 4) != 0) { 45 SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Revision should start with SDL-"); 46 return 1; 47 } 48 SDL_Quit(); 49 return 0; 50} 51[FILE END](C) 2025 0x4248 (C) 2025 4248 Media and 4248 Systems, All part of 0x4248 See LICENCE files for more information. Not all files are by 0x4248 always check Licencing.