SDL_version.h 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. /*
  2. Simple DirectMedia Layer
  3. Copyright (C) 1997-2025 Sam Lantinga <slouken@libsdl.org>
  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. Permission is granted to anyone to use this software for any purpose,
  8. including commercial applications, and to alter it and redistribute it
  9. freely, subject to the following restrictions:
  10. 1. The origin of this software must not be misrepresented; you must not
  11. claim that you wrote the original software. If you use this software
  12. in a product, an acknowledgment in the product documentation would be
  13. appreciated but is not required.
  14. 2. Altered source versions must be plainly marked as such, and must not be
  15. misrepresented as being the original software.
  16. 3. This notice may not be removed or altered from any source distribution.
  17. */
  18. /**
  19. * # CategoryVersion
  20. *
  21. * Functionality to query the current SDL version, both as headers the app was
  22. * compiled against, and a library the app is linked to.
  23. */
  24. #ifndef SDL_version_h_
  25. #define SDL_version_h_
  26. #include <SDL3/SDL_stdinc.h>
  27. #include <SDL3/SDL_begin_code.h>
  28. /* Set up for C function definitions, even when using C++ */
  29. #ifdef __cplusplus
  30. extern "C" {
  31. #endif
  32. /**
  33. * The current major version of SDL headers.
  34. *
  35. * If this were SDL version 3.2.1, this value would be 3.
  36. *
  37. * \since This macro is available since SDL 3.1.3.
  38. */
  39. #define SDL_MAJOR_VERSION 3
  40. /**
  41. * The current minor version of the SDL headers.
  42. *
  43. * If this were SDL version 3.2.1, this value would be 2.
  44. *
  45. * \since This macro is available since SDL 3.1.3.
  46. */
  47. #define SDL_MINOR_VERSION 1
  48. /**
  49. * The current micro (or patchlevel) version of the SDL headers.
  50. *
  51. * If this were SDL version 3.2.1, this value would be 1.
  52. *
  53. * \since This macro is available since SDL 3.1.3.
  54. */
  55. #define SDL_MICRO_VERSION 10
  56. /**
  57. * This macro turns the version numbers into a numeric value.
  58. *
  59. * (1,2,3) becomes 1002003.
  60. *
  61. * \param major the major version number.
  62. * \param minor the minorversion number.
  63. * \param patch the patch version number.
  64. *
  65. * \since This macro is available since SDL 3.1.3.
  66. */
  67. #define SDL_VERSIONNUM(major, minor, patch) \
  68. ((major) * 1000000 + (minor) * 1000 + (patch))
  69. /**
  70. * This macro extracts the major version from a version number
  71. *
  72. * 1002003 becomes 1.
  73. *
  74. * \param version the version number.
  75. *
  76. * \since This macro is available since SDL 3.1.3.
  77. */
  78. #define SDL_VERSIONNUM_MAJOR(version) ((version) / 1000000)
  79. /**
  80. * This macro extracts the minor version from a version number
  81. *
  82. * 1002003 becomes 2.
  83. *
  84. * \param version the version number.
  85. *
  86. * \since This macro is available since SDL 3.1.3.
  87. */
  88. #define SDL_VERSIONNUM_MINOR(version) (((version) / 1000) % 1000)
  89. /**
  90. * This macro extracts the micro version from a version number
  91. *
  92. * 1002003 becomes 3.
  93. *
  94. * \param version the version number.
  95. *
  96. * \since This macro is available since SDL 3.1.3.
  97. */
  98. #define SDL_VERSIONNUM_MICRO(version) ((version) % 1000)
  99. /**
  100. * This is the version number macro for the current SDL version.
  101. *
  102. * \since This macro is available since SDL 3.1.3.
  103. *
  104. * \sa SDL_GetVersion
  105. */
  106. #define SDL_VERSION \
  107. SDL_VERSIONNUM(SDL_MAJOR_VERSION, SDL_MINOR_VERSION, SDL_MICRO_VERSION)
  108. /**
  109. * This macro will evaluate to true if compiled with SDL at least X.Y.Z.
  110. *
  111. * \since This macro is available since SDL 3.1.3.
  112. */
  113. #define SDL_VERSION_ATLEAST(X, Y, Z) \
  114. (SDL_VERSION >= SDL_VERSIONNUM(X, Y, Z))
  115. /**
  116. * Get the version of SDL that is linked against your program.
  117. *
  118. * If you are linking to SDL dynamically, then it is possible that the current
  119. * version will be different than the version you compiled against. This
  120. * function returns the current version, while SDL_VERSION is the version you
  121. * compiled with.
  122. *
  123. * This function may be called safely at any time, even before SDL_Init().
  124. *
  125. * \returns the version of the linked library.
  126. *
  127. * \since This function is available since SDL 3.1.3.
  128. *
  129. * \sa SDL_GetRevision
  130. */
  131. extern SDL_DECLSPEC int SDLCALL SDL_GetVersion(void);
  132. /**
  133. * Get the code revision of SDL that is linked against your program.
  134. *
  135. * This value is the revision of the code you are linked with and may be
  136. * different from the code you are compiling with, which is found in the
  137. * constant SDL_REVISION.
  138. *
  139. * The revision is arbitrary string (a hash value) uniquely identifying the
  140. * exact revision of the SDL library in use, and is only useful in comparing
  141. * against other revisions. It is NOT an incrementing number.
  142. *
  143. * If SDL wasn't built from a git repository with the appropriate tools, this
  144. * will return an empty string.
  145. *
  146. * You shouldn't use this function for anything but logging it for debugging
  147. * purposes. The string is not intended to be reliable in any way.
  148. *
  149. * \returns an arbitrary string, uniquely identifying the exact revision of
  150. * the SDL library in use.
  151. *
  152. * \since This function is available since SDL 3.1.3.
  153. *
  154. * \sa SDL_GetVersion
  155. */
  156. extern SDL_DECLSPEC const char * SDLCALL SDL_GetRevision(void);
  157. /* Ends C function definitions when using C++ */
  158. #ifdef __cplusplus
  159. }
  160. #endif
  161. #include <SDL3/SDL_close_code.h>
  162. #endif /* SDL_version_h_ */