mirror of https://github.com/encounter/SDL.git
Always define SDL_COMPILE_TIME_ASSERT as static_assert() in C++
Apparently some versions of gcc will define __STDC_VERSION__ even when compiling in C++ mode. Fixes https://github.com/libsdl-org/SDL/issues/6078
This commit is contained in:
parent
3bae2d57da
commit
f6b81125b3
|
@ -373,14 +373,22 @@ typedef uint64_t Uint64;
|
||||||
#endif
|
#endif
|
||||||
#endif /* SDL_DISABLE_ANALYZE_MACROS */
|
#endif /* SDL_DISABLE_ANALYZE_MACROS */
|
||||||
|
|
||||||
#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L)
|
#ifndef SDL_COMPILE_TIME_ASSERT
|
||||||
#define SDL_COMPILE_TIME_ASSERT(name, x) _Static_assert(x, #x)
|
#if defined(__cplusplus)
|
||||||
#elif defined(__cplusplus) && (__cplusplus >= 201103L)
|
#if (__cplusplus >= 201103L)
|
||||||
#define SDL_COMPILE_TIME_ASSERT(name, x) static_assert(x, #x)
|
#define SDL_COMPILE_TIME_ASSERT(name, x) static_assert(x, #x)
|
||||||
#else /* universal, but may trigger -Wunused-local-typedefs */
|
#endif
|
||||||
|
#elif defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L)
|
||||||
|
#define SDL_COMPILE_TIME_ASSERT(name, x) _Static_assert(x, #x)
|
||||||
|
#endif
|
||||||
|
#endif /* !SDL_COMPILE_TIME_ASSERT */
|
||||||
|
|
||||||
|
#ifndef SDL_COMPILE_TIME_ASSERT
|
||||||
|
/* universal, but may trigger -Wunused-local-typedefs */
|
||||||
#define SDL_COMPILE_TIME_ASSERT(name, x) \
|
#define SDL_COMPILE_TIME_ASSERT(name, x) \
|
||||||
typedef int SDL_compile_time_assert_ ## name[(x) * 2 - 1]
|
typedef int SDL_compile_time_assert_ ## name[(x) * 2 - 1]
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/** \cond */
|
/** \cond */
|
||||||
#ifndef DOXYGEN_SHOULD_IGNORE_THIS
|
#ifndef DOXYGEN_SHOULD_IGNORE_THIS
|
||||||
SDL_COMPILE_TIME_ASSERT(uint8, sizeof(Uint8) == 1);
|
SDL_COMPILE_TIME_ASSERT(uint8, sizeof(Uint8) == 1);
|
||||||
|
|
Loading…
Reference in New Issue