Skip to content

Commit 6a68618

Browse files
committed
SDL_begin_code.h: Actually define SDL_RESTRICT.
We wrote documentation for this but never actually filled in the code.
1 parent 51dfca8 commit 6a68618

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

include/SDL3/SDL_begin_code.h

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -261,9 +261,9 @@
261261
*
262262
* On compilers without restrict support, this is defined to nothing.
263263
*
264-
* \since This macro is available since SDL 3.2.0.
264+
* \since This macro is available since SDL 3.4.0.
265265
*/
266-
#define SDL_RESTRICT __restrict__
266+
#define SDL_RESTRICT __restrict
267267

268268
/**
269269
* Check if the compiler supports a given builtin functionality.
@@ -325,6 +325,17 @@
325325
/* end of wiki documentation section. */
326326
#endif
327327

328+
/* `restrict` is from C99, but __restrict works with both Visual Studio and GCC. */
329+
#ifndef SDL_RESTRICT
330+
# if defined(restrict) || ((defined(__STDC_VERSION__) && (__STDC_VERSION__ < 199901)))
331+
# defined SDL_RESTRICT restrict
332+
# elif defined(_MSC_VER) || defined(__GNUC__) || defined(__clang__)
333+
# define SDL_RESTRICT __restrict
334+
# else
335+
# define SDL_RESTRICT
336+
# endif
337+
#endif
338+
328339
#ifndef SDL_HAS_BUILTIN
329340
#ifdef __has_builtin
330341
#define SDL_HAS_BUILTIN(x) __has_builtin(x)

0 commit comments

Comments
 (0)