Make SDL_VERSION_ATLEAST future-proof against larger version numbers

This comparison normally happens at compile-time, not at runtime, so
it doesn't matter if it isn't optimal. This avoids incorrect comparison
if the minor version in SDL_COMPILEDVERSION and SDL_VERSIONNUM has more
than one digit, which would cause it to overflow from the hundreds place
into the thousands place.

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

View File

@ -104,7 +104,9 @@ typedef struct SDL_version
* This macro will evaluate to true if compiled with SDL at least X.Y.Z.
*/
#define SDL_VERSION_ATLEAST(X, Y, Z) \
(SDL_COMPILEDVERSION >= SDL_VERSIONNUM(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))
/**
* Get the version of SDL that is linked against your program.