SDL_version.h 5.5 KB

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