SDL_version.h 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. /*
  2. Simple DirectMedia Layer
  3. Copyright (C) 1997-2020 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 "SDL_stdinc.h"
  26. #include "begin_code.h"
  27. /* Set up for C function definitions, even when using C++ */
  28. #ifdef __cplusplus
  29. extern "C" {
  30. #endif
  31. /**
  32. * \brief Information the version of SDL in use.
  33. *
  34. * Represents the library's version as three levels: major revision
  35. * (increments with massive changes, additions, and enhancements),
  36. * minor revision (increments with backwards-compatible changes to the
  37. * major revision), and patchlevel (increments with fixes to the minor
  38. * revision).
  39. *
  40. * \sa SDL_VERSION
  41. * \sa SDL_GetVersion
  42. */
  43. typedef struct SDL_version
  44. {
  45. Uint8 major; /**< major version */
  46. Uint8 minor; /**< minor version */
  47. Uint8 patch; /**< update version */
  48. } SDL_version;
  49. /* Printable format: "%d.%d.%d", MAJOR, MINOR, PATCHLEVEL
  50. */
  51. #define SDL_MAJOR_VERSION 2
  52. #define SDL_MINOR_VERSION 0
  53. #define SDL_PATCHLEVEL 14
  54. /**
  55. * \brief Macro to determine SDL version program was compiled against.
  56. *
  57. * This macro fills in a SDL_version structure with the version of the
  58. * library you compiled against. This is determined by what header the
  59. * compiler uses. Note that if you dynamically linked the library, you might
  60. * have a slightly newer or older version at runtime. That version can be
  61. * determined with SDL_GetVersion(), which, unlike SDL_VERSION(),
  62. * is not a macro.
  63. *
  64. * \param x A pointer to a SDL_version struct to initialize.
  65. *
  66. * \sa SDL_version
  67. * \sa SDL_GetVersion
  68. */
  69. #define SDL_VERSION(x) \
  70. { \
  71. (x)->major = SDL_MAJOR_VERSION; \
  72. (x)->minor = SDL_MINOR_VERSION; \
  73. (x)->patch = SDL_PATCHLEVEL; \
  74. }
  75. /**
  76. * This macro turns the version numbers into a numeric value:
  77. * \verbatim
  78. (1,2,3) -> (1203)
  79. \endverbatim
  80. *
  81. * This assumes that there will never be more than 100 patchlevels.
  82. */
  83. #define SDL_VERSIONNUM(X, Y, Z) \
  84. ((X)*1000 + (Y)*100 + (Z))
  85. /**
  86. * This is the version number macro for the current SDL version.
  87. */
  88. #define SDL_COMPILEDVERSION \
  89. SDL_VERSIONNUM(SDL_MAJOR_VERSION, SDL_MINOR_VERSION, SDL_PATCHLEVEL)
  90. /**
  91. * This macro will evaluate to true if compiled with SDL at least X.Y.Z.
  92. */
  93. #define SDL_VERSION_ATLEAST(X, Y, Z) \
  94. (SDL_COMPILEDVERSION >= SDL_VERSIONNUM(X, Y, Z))
  95. /**
  96. * \brief 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
  99. * current version will be different than the version you compiled against.
  100. * This function returns the current version, while SDL_VERSION() is a
  101. * macro that tells you what version you compiled with.
  102. *
  103. * \code
  104. * SDL_version compiled;
  105. * SDL_version linked;
  106. *
  107. * SDL_VERSION(&compiled);
  108. * SDL_GetVersion(&linked);
  109. * printf("We compiled against SDL version %d.%d.%d ...\n",
  110. * compiled.major, compiled.minor, compiled.patch);
  111. * printf("But we linked against SDL version %d.%d.%d.\n",
  112. * linked.major, linked.minor, linked.patch);
  113. * \endcode
  114. *
  115. * This function may be called safely at any time, even before SDL_Init().
  116. *
  117. * \sa SDL_VERSION
  118. */
  119. extern DECLSPEC void SDLCALL SDL_GetVersion(SDL_version * ver);
  120. /**
  121. * \brief Get the code revision of SDL that is linked against your program.
  122. *
  123. * Returns an arbitrary string (a hash value) uniquely identifying the
  124. * exact revision of the SDL library in use, and is only useful in comparing
  125. * against other revisions. It is NOT an incrementing number.
  126. */
  127. extern DECLSPEC const char *SDLCALL SDL_GetRevision(void);
  128. /**
  129. * \brief Get the revision number of SDL that is linked against your program.
  130. *
  131. * Returns a number uniquely identifying the exact revision of the SDL
  132. * library in use. It is an incrementing number based on commits to
  133. * hg.libsdl.org.
  134. */
  135. extern DECLSPEC int SDLCALL SDL_GetRevisionNumber(void);
  136. /* Ends C function definitions when using C++ */
  137. #ifdef __cplusplus
  138. }
  139. #endif
  140. #include "close_code.h"
  141. #endif /* SDL_version_h_ */
  142. /* vi: set ts=4 sw=4 expandtab: */