testver.c 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. /*
  2. Copyright (C) 1997-2025 Sam Lantinga <slouken@libsdl.org>
  3. This software is provided 'as-is', without any express or implied
  4. warranty. In no event will the authors be held liable for any damages
  5. arising from the use of this software.
  6. Permission is granted to anyone to use this software for any purpose,
  7. including commercial applications, and to alter it and redistribute it
  8. freely.
  9. */
  10. /* Test program to compare the compile-time version of SDL with the linked
  11. version of SDL
  12. */
  13. #include <SDL3/SDL.h>
  14. #include <SDL3/SDL_main.h>
  15. #include <SDL3/SDL_revision.h>
  16. int main(int argc, char *argv[])
  17. {
  18. if (argc > 1) {
  19. SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "USAGE: %s", argv[0]);
  20. return 1;
  21. }
  22. #if SDL_VERSION_ATLEAST(3, 0, 0)
  23. SDL_Log("Compiled with SDL 3.0 or newer");
  24. #else
  25. SDL_Log("Compiled with SDL older than 3.0");
  26. #endif
  27. SDL_Log("Compiled version: %d.%d.%d (%s)",
  28. SDL_MAJOR_VERSION, SDL_MINOR_VERSION, SDL_MICRO_VERSION,
  29. SDL_REVISION);
  30. int version = SDL_GetVersion();
  31. SDL_Log("Runtime version: %d.%d.%d (%s)",
  32. SDL_VERSIONNUM_MAJOR(version), SDL_VERSIONNUM_MINOR(version), SDL_VERSIONNUM_MICRO(version),
  33. SDL_GetRevision());
  34. SDL_Quit();
  35. return 0;
  36. }