From 6a686185f770707ab8359352e8bd828595c23adc Mon Sep 17 00:00:00 2001
From: "Ryan C. Gordon" <[EMAIL REDACTED]>
Date: Fri, 30 May 2025 15:58:44 -0400
Subject: [PATCH] SDL_begin_code.h: Actually define SDL_RESTRICT.
We wrote documentation for this but never actually filled in the code.
---
include/SDL3/SDL_begin_code.h | 15 +++++++++++++--
1 file changed, 13 insertions(+), 2 deletions(-)
diff --git a/include/SDL3/SDL_begin_code.h b/include/SDL3/SDL_begin_code.h
index 4b86681f423a6..79035b72a5883 100644
--- a/include/SDL3/SDL_begin_code.h
+++ b/include/SDL3/SDL_begin_code.h
@@ -261,9 +261,9 @@
*
* On compilers without restrict support, this is defined to nothing.
*
- * \since This macro is available since SDL 3.2.0.
+ * \since This macro is available since SDL 3.4.0.
*/
-#define SDL_RESTRICT __restrict__
+#define SDL_RESTRICT __restrict
/**
* Check if the compiler supports a given builtin functionality.
@@ -325,6 +325,17 @@
/* end of wiki documentation section. */
#endif
+/* `restrict` is from C99, but __restrict works with both Visual Studio and GCC. */
+#ifndef SDL_RESTRICT
+# if defined(restrict) || ((defined(__STDC_VERSION__) && (__STDC_VERSION__ < 199901)))
+# defined SDL_RESTRICT restrict
+# elif defined(_MSC_VER) || defined(__GNUC__) || defined(__clang__)
+# define SDL_RESTRICT __restrict
+# else
+# define SDL_RESTRICT
+# endif
+#endif
+
#ifndef SDL_HAS_BUILTIN
#ifdef __has_builtin
#define SDL_HAS_BUILTIN(x) __has_builtin(x)