Merge pull request #8650 from douzzer/20250408-wc_static_assert_dummy_struct-gcxx-6v5

20250408-wc_static_assert_dummy_struct-gcxx-6v5
pull/8654/head
Sean Parkinson 2025-04-09 07:36:28 +10:00 committed by GitHub
commit 791bda3323
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 13 additions and 7 deletions

View File

@ -887,6 +887,7 @@ __BIG_ENDIAN__
__BORLANDC__
__CCRX__
__COMPILER_VER__
__COUNTER__
__CYGWIN__
__DATE__
__DCACHE_PRESENT

View File

@ -1806,8 +1806,8 @@ typedef struct w64wrapper {
#define PRAGMA_DIAG_POP /* null expansion */
#endif
#define WC_CPP_CAT_(a, b) a ## b
#define WC_CPP_CAT(a, b) WC_CPP_CAT_(a, b)
#define WC_CPP_CAT4_(a, b, c, d) a ## b ## c ## d
#define WC_CPP_CAT4(a, b, c, d) WC_CPP_CAT4_(a, b, c, d)
#if defined(WC_NO_STATIC_ASSERT)
#define wc_static_assert(expr) struct wc_static_assert_dummy_struct
#define wc_static_assert2(expr, msg) wc_static_assert(expr)
@ -1844,11 +1844,16 @@ typedef struct w64wrapper {
#define wc_static_assert2(expr, msg) _Static_assert(expr, msg)
#endif
#else
/* C89-compatible fallback */
#define wc_static_assert(expr) \
struct WC_CPP_CAT(wc_static_assert_dummy_struct_L, __LINE__) { \
char t[(expr) ? 1 : -1]; \
}
#ifdef __COUNTER__
#define wc_static_assert(expr) \
struct WC_CPP_CAT4(wc_static_assert_dummy_struct_L, \
__LINE__, _, __COUNTER__) { \
char t[(expr) ? 1 : -1]; \
}
#else
#define wc_static_assert(expr) \
struct wc_static_assert_dummy_struct
#endif
#ifndef wc_static_assert2
#define wc_static_assert2(expr, msg) wc_static_assert(expr)
#endif