Browse Source

Updated SDL_VERSIONNUM macro for new SDL version convention

Fixes https://github.com/libsdl-org/SDL/issues/6578
Sam Lantinga 2 years ago
parent
commit
01d137592c
1 changed files with 4 additions and 22 deletions
  1. 4 22
      include/SDL_version.h

+ 4 - 22
include/SDL_version.h

@@ -83,44 +83,26 @@ typedef struct SDL_version
     (x)->patch = SDL_PATCHLEVEL;                    \
 }
 
-/* TODO: Remove this whole block in SDL 3 */
-#if SDL_MAJOR_VERSION <= 3
 /**
  *  This macro turns the version numbers into a numeric value:
  *  \verbatim
-    (1,2,3) -> (1203)
+    (1,2,3) -> (0x1000203)
     \endverbatim
- *
- *  This assumes that there will never be more than 100 patchlevels.
- *
- *  In versions higher than 2.9.0, the minor version overflows into
- *  the thousands digit: for example, 2.23.0 is encoded as 4300,
- *  and 2.255.99 would be encoded as 25799.
- *  This macro will not be available in SDL 3.x.
  */
-#define SDL_VERSIONNUM(X, Y, Z)                     \
-    ((X)*1000 + (Y)*100 + (Z))
+#define SDL_VERSIONNUM(X, Y, Z) \
+    ((X) << 24 | (Y) << 8 | (Z) << 0)
 
 /**
  *  This is the version number macro for the current SDL version.
- *
- *  In versions higher than 2.9.0, the minor version overflows into
- *  the thousands digit: for example, 2.23.0 is encoded as 4300.
- *  This macro will not be available in SDL 3.x.
- *
- *  Deprecated, use SDL_VERSION_ATLEAST or SDL_VERSION instead.
  */
 #define SDL_COMPILEDVERSION \
     SDL_VERSIONNUM(SDL_MAJOR_VERSION, SDL_MINOR_VERSION, SDL_PATCHLEVEL)
-#endif /* SDL_MAJOR_VERSION < 3 */
 
 /**
  *  This macro will evaluate to true if compiled with SDL at least X.Y.Z.
  */
 #define SDL_VERSION_ATLEAST(X, Y, Z) \
-    ((SDL_MAJOR_VERSION >= X) && \
-     (SDL_MAJOR_VERSION > X || SDL_MINOR_VERSION >= Y) && \
-     (SDL_MAJOR_VERSION > X || SDL_MINOR_VERSION > Y || SDL_PATCHLEVEL >= Z))
+    (SDL_COMPILEDVERSION >= SDL_VERSIONUM(X, Y, Z))
 
 /**
  * Get the version of SDL that is linked against your program.