Deprecate SDL_COMPILEDVERSION and SDL_VERSIONNUM, to be removed in 3.x

The encoding used in SDL_VERSIONNUM (e.g. 2.0.22 -> 2022) cannot
represent 2-digit minor versions without overflowing from the hundreds
digit into the thousands digit, which produces confusing version
numbers that will compare incorrectly when the major version is increased
to 3.

However, we can sidestep this problem by declaring that SDL_VERSIONNUM
will no longer be present in SDL 3, which means it only needs to be able
to represent SDL 2 version numbers losslessly.

Signed-off-by: Simon McVittie <smcv@collabora.com>
This commit is contained in:
Simon McVittie 2022-05-03 13:08:38 +01:00 committed by Sam Lantinga
parent f9a5cf77b8
commit e0daa2a530
1 changed files with 8 additions and 0 deletions

View File

@ -83,6 +83,8 @@ 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
@ -90,15 +92,21 @@ typedef struct SDL_version
\endverbatim \endverbatim
* *
* This assumes that there will never be more than 100 patchlevels. * This assumes that there will never be more than 100 patchlevels.
* 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)*1000 + (Y)*100 + (Z))
/** /**
* This is the version number macro for the current SDL version. * This is the version number macro for the current SDL version.
*
* 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.