From 1ca76a29d9204ab01f9a414d96a30d2a7045dc00 Mon Sep 17 00:00:00 2001 From: Ozkan Sezer Date: Mon, 22 Jul 2024 15:55:40 +0300 Subject: [PATCH] SDL_stdinc.h (SDL_COMPILE_TIME_ASSERT): Keep C++ case alone (after PR/10331) Some versions of gcc will define __STDC_VERSION__ even when compiling in C++ mode. Reference issue: https://github.com/libsdl-org/SDL/issues/6078 which was fixed by https://github.com/libsdl-org/SDL/commit/f6b81125b340e00129978f2c9eebfba6a4d25692 (cherry picked from commit 70c1012e8c76a662bb59554e4be8f9660e2b5708) (cherry picked from commit 86b4d035dbc538db3cb6f41fe4ddaaab9bd2cf64) --- include/SDL_stdinc.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/include/SDL_stdinc.h b/include/SDL_stdinc.h index 8b94ecb284..8113f453f3 100644 --- a/include/SDL_stdinc.h +++ b/include/SDL_stdinc.h @@ -376,7 +376,12 @@ typedef uint64_t Uint64; #endif /* SDL_DISABLE_ANALYZE_MACROS */ #ifndef SDL_COMPILE_TIME_ASSERT -#if (defined(__cplusplus) && __cplusplus >= 201103L) || (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202311L) +#if defined(__cplusplus) +/* Keep C++ case alone: Some versions of gcc will define __STDC_VERSION__ even when compiling in C++ mode. */ +#if (__cplusplus >= 201103L) +#define SDL_COMPILE_TIME_ASSERT(name, x) static_assert(x, #x) +#endif +#elif defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 202311L) #define SDL_COMPILE_TIME_ASSERT(name, x) static_assert(x, #x) #elif defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L) #define SDL_COMPILE_TIME_ASSERT(name, x) _Static_assert(x, #x)