mirror of https://github.com/wolfSSL/wolfssl.git
wolfssl/wolfcrypt/types.h: refactor fallback implementation of wc_static_assert() to depend on __COUNTER__, to avoid namespace collisions on unlucky macro invocations with same line numbers.
parent
6d299ea943
commit
e1ece63942
|
@ -887,6 +887,7 @@ __BIG_ENDIAN__
|
|||
__BORLANDC__
|
||||
__CCRX__
|
||||
__COMPILER_VER__
|
||||
__COUNTER__
|
||||
__CYGWIN__
|
||||
__DATE__
|
||||
__DCACHE_PRESENT
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue