SDL_version.h 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. /*
  2. Simple DirectMedia Layer
  3. Copyright (C) 1997-2024 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. * \file SDL_version.h
  20. *
  21. * This header defines the current SDL version.
  22. */
  23. #ifndef SDL_version_h_
  24. #define SDL_version_h_
  25. #include <SDL3/SDL_stdinc.h>
  26. #include <SDL3/SDL_error.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 version of SDL
  34. */
  35. #define SDL_MAJOR_VERSION 3
  36. #define SDL_MINOR_VERSION 1
  37. #define SDL_MICRO_VERSION 2
  38. /**
  39. * This macro turns the version numbers into a numeric value.
  40. *
  41. * (1,2,3) becomes 1002003.
  42. *
  43. * \param major the major version number.
  44. * \param minor the minorversion number.
  45. * \param patch the patch version number.
  46. *
  47. * \since This macro is available since SDL 3.0.0.
  48. */
  49. #define SDL_VERSIONNUM(major, minor, patch) \
  50. ((major) * 1000000 + (minor) * 1000 + (patch))
  51. /**
  52. * This macro extracts the major version from a version number
  53. *
  54. * 1002003 becomes 1.
  55. *
  56. * \param version the version number.
  57. *
  58. * \since This macro is available since SDL 3.0.0.
  59. */
  60. #define SDL_VERSIONNUM_MAJOR(version) ((version) / 1000000)
  61. /**
  62. * This macro extracts the minor version from a version number
  63. *
  64. * 1002003 becomes 2.
  65. *
  66. * \param version the version number.
  67. *
  68. * \since This macro is available since SDL 3.0.0.
  69. */
  70. #define SDL_VERSIONNUM_MINOR(version) (((version) / 1000) % 1000)
  71. /**
  72. * This macro extracts the micro version from a version number
  73. *
  74. * 1002003 becomes 3.
  75. *
  76. * \param version the version number.
  77. *
  78. * \since This macro is available since SDL 3.0.0.
  79. */
  80. #define SDL_VERSIONNUM_MICRO(version) ((version) % 1000)
  81. /**
  82. * This is the version number macro for the current SDL version.
  83. *
  84. * \since This macro is available since SDL 3.0.0.
  85. */
  86. #define SDL_VERSION \
  87. SDL_VERSIONNUM(SDL_MAJOR_VERSION, SDL_MINOR_VERSION, SDL_MICRO_VERSION)
  88. /**
  89. * This macro will evaluate to true if compiled with SDL at least X.Y.Z.
  90. *
  91. * \since This macro is available since SDL 3.0.0.
  92. */
  93. #define SDL_VERSION_ATLEAST(X, Y, Z) \
  94. (SDL_VERSION >= SDL_VERSIONNUM(X, Y, Z))
  95. /**
  96. * Get the version of SDL that is linked against your program.
  97. *
  98. * If you are linking to SDL dynamically, then it is possible that the current
  99. * version will be different than the version you compiled against. This
  100. * function returns the current version, while SDL_VERSION is the version you
  101. * compiled with.
  102. *
  103. * This function may be called safely at any time, even before SDL_Init().
  104. *
  105. * \returns the version of the linked library.
  106. *
  107. * \since This function is available since SDL 3.0.0.
  108. *
  109. * \sa SDL_GetRevision
  110. */
  111. extern DECLSPEC int SDLCALL SDL_GetVersion(void);
  112. /**
  113. * Get the code revision of SDL that is linked against your program.
  114. *
  115. * This value is the revision of the code you are linked with and may be
  116. * different from the code you are compiling with, which is found in the
  117. * constant SDL_REVISION.
  118. *
  119. * The revision is arbitrary string (a hash value) uniquely identifying the
  120. * exact revision of the SDL library in use, and is only useful in comparing
  121. * against other revisions. It is NOT an incrementing number.
  122. *
  123. * If SDL wasn't built from a git repository with the appropriate tools, this
  124. * will return an empty string.
  125. *
  126. * You shouldn't use this function for anything but logging it for debugging
  127. * purposes. The string is not intended to be reliable in any way.
  128. *
  129. * \returns an arbitrary string, uniquely identifying the exact revision of
  130. * the SDL library in use.
  131. *
  132. * \since This function is available since SDL 3.0.0.
  133. *
  134. * \sa SDL_GetVersion
  135. */
  136. extern DECLSPEC const char *SDLCALL SDL_GetRevision(void);
  137. /* Ends C function definitions when using C++ */
  138. #ifdef __cplusplus
  139. }
  140. #endif
  141. #include <SDL3/SDL_close_code.h>
  142. #endif /* SDL_version_h_ */