From f9a5cf77b8e8b4703a4ef6f4ba7f2394cb7ee562 Mon Sep 17 00:00:00 2001
From: Simon McVittie <[EMAIL REDACTED]>
Date: Tue, 3 May 2022 13:05:02 +0100
Subject: [PATCH] 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>
---
include/SDL_version.h | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/include/SDL_version.h b/include/SDL_version.h
index f24fa810c9c..5bdff3b8412 100644
--- a/include/SDL_version.h
+++ b/include/SDL_version.h
@@ -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.