SDL_version.h 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  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. * Information about the version of SDL in use.
  34. *
  35. * Represents the library's version as three levels: major revision
  36. * (increments with massive changes, additions, and enhancements),
  37. * minor revision (increments with backwards-compatible changes to the
  38. * major revision), and patchlevel (increments with fixes to the minor
  39. * revision).
  40. *
  41. * \sa SDL_VERSION
  42. * \sa SDL_GetVersion
  43. *
  44. * \since This struct is available since SDL 3.0.0.
  45. */
  46. typedef struct SDL_Version
  47. {
  48. Uint8 major; /**< major version */
  49. Uint8 minor; /**< minor version */
  50. Uint8 patch; /**< update version */
  51. } SDL_Version;
  52. /* Printable format: "%d.%d.%d", MAJOR, MINOR, PATCHLEVEL */
  53. #define SDL_MAJOR_VERSION 3
  54. #define SDL_MINOR_VERSION 1
  55. #define SDL_PATCHLEVEL 1
  56. /**
  57. * Macro to determine SDL version program was compiled against.
  58. *
  59. * This macro fills in an SDL_Version structure with the version of the
  60. * library you compiled against. This is determined by what header the
  61. * compiler uses. Note that if you dynamically linked the library, you might
  62. * have a slightly newer or older version at runtime. That version can be
  63. * determined with SDL_GetVersion(), which, unlike SDL_VERSION(),
  64. * is not a macro.
  65. *
  66. * \param x A pointer to an SDL_Version struct to initialize.
  67. *
  68. * \sa SDL_Version
  69. * \sa SDL_GetVersion
  70. *
  71. * \since This macro is available since SDL 3.0.0.
  72. */
  73. #define SDL_VERSION(x) \
  74. { \
  75. (x)->major = SDL_MAJOR_VERSION; \
  76. (x)->minor = SDL_MINOR_VERSION; \
  77. (x)->patch = SDL_PATCHLEVEL; \
  78. }
  79. /**
  80. * This macro turns the version numbers into a numeric value.
  81. *
  82. * (1,2,3) becomes 0x1000203.
  83. *
  84. * \param major the major version number.
  85. * \param minor the minorversion number.
  86. * \param patch the patch version number.
  87. *
  88. * \since This macro is available since SDL 3.0.0.
  89. */
  90. #define SDL_VERSIONNUM(major, minor, patch) \
  91. ((major) << 24 | (minor) << 8 | (patch) << 0)
  92. /**
  93. * This is the version number macro for the current SDL version.
  94. *
  95. * \since This macro is available since SDL 3.0.0.
  96. */
  97. #define SDL_COMPILEDVERSION \
  98. SDL_VERSIONNUM(SDL_MAJOR_VERSION, SDL_MINOR_VERSION, SDL_PATCHLEVEL)
  99. /**
  100. * This macro will evaluate to true if compiled with SDL at least X.Y.Z.
  101. *
  102. * \since This macro is available since SDL 3.0.0.
  103. */
  104. #define SDL_VERSION_ATLEAST(X, Y, Z) \
  105. (SDL_COMPILEDVERSION >= SDL_VERSIONNUM(X, Y, Z))
  106. /**
  107. * Get the version of SDL that is linked against your program.
  108. *
  109. * If you are linking to SDL dynamically, then it is possible that the current
  110. * version will be different than the version you compiled against. This
  111. * function returns the current version, while SDL_VERSION() is a macro that
  112. * tells you what version you compiled with.
  113. *
  114. * This function may be called safely at any time, even before SDL_Init().
  115. *
  116. * \param ver the SDL_Version structure that contains the version information
  117. * \returns 0 on success or a negative error code on failure; call
  118. * SDL_GetError() for more information.
  119. *
  120. * \since This function is available since SDL 3.0.0.
  121. *
  122. * \sa SDL_GetRevision
  123. */
  124. extern DECLSPEC int SDLCALL SDL_GetVersion(SDL_Version * ver);
  125. /**
  126. * Get the code revision of SDL that is linked against your program.
  127. *
  128. * This value is the revision of the code you are linked with and may be
  129. * different from the code you are compiling with, which is found in the
  130. * constant SDL_REVISION.
  131. *
  132. * The revision is arbitrary string (a hash value) uniquely identifying the
  133. * exact revision of the SDL library in use, and is only useful in comparing
  134. * against other revisions. It is NOT an incrementing number.
  135. *
  136. * If SDL wasn't built from a git repository with the appropriate tools, this
  137. * will return an empty string.
  138. *
  139. * Prior to SDL 2.0.16, before development moved to GitHub, this returned a
  140. * hash for a Mercurial repository.
  141. *
  142. * You shouldn't use this function for anything but logging it for debugging
  143. * purposes. The string is not intended to be reliable in any way.
  144. *
  145. * \returns an arbitrary string, uniquely identifying the exact revision of
  146. * the SDL library in use.
  147. *
  148. * \since This function is available since SDL 3.0.0.
  149. *
  150. * \sa SDL_GetVersion
  151. */
  152. extern DECLSPEC const char *SDLCALL SDL_GetRevision(void);
  153. /* Ends C function definitions when using C++ */
  154. #ifdef __cplusplus
  155. }
  156. #endif
  157. #include <SDL3/SDL_close_code.h>
  158. #endif /* SDL_version_h_ */