Updated SDL_VERSIONNUM macro for new SDL version convention

Fixes https://github.com/libsdl-org/SDL/issues/6578
main
Sam Lantinga 2022-11-22 07:56:43 -08:00
parent 63243eb3a5
commit 01d137592c
1 changed files with 4 additions and 22 deletions

View File

@ -83,44 +83,26 @@ typedef struct SDL_version
(x)->patch = SDL_PATCHLEVEL; \ (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: * This macro turns the version numbers into a numeric value:
* \verbatim * \verbatim
(1,2,3) -> (1203) (1,2,3) -> (0x1000203)
\endverbatim \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) \ #define SDL_VERSIONNUM(X, Y, Z) \
((X)*1000 + (Y)*100 + (Z)) ((X) << 24 | (Y) << 8 | (Z) << 0)
/** /**
* This is the version number macro for the current SDL version. * 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 \ #define SDL_COMPILEDVERSION \
SDL_VERSIONNUM(SDL_MAJOR_VERSION, SDL_MINOR_VERSION, SDL_PATCHLEVEL) 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. * This macro will evaluate to true if compiled with SDL at least X.Y.Z.
*/ */
#define SDL_VERSION_ATLEAST(X, Y, Z) \ #define SDL_VERSION_ATLEAST(X, Y, Z) \
((SDL_MAJOR_VERSION >= X) && \ (SDL_COMPILEDVERSION >= SDL_VERSIONUM(X, Y, Z))
(SDL_MAJOR_VERSION > X || SDL_MINOR_VERSION >= Y) && \
(SDL_MAJOR_VERSION > X || SDL_MINOR_VERSION > Y || SDL_PATCHLEVEL >= Z))
/** /**
* Get the version of SDL that is linked against your program. * Get the version of SDL that is linked against your program.