mirror of
https://github.com/wolfSSL/wolfssl.git
synced 2025-08-02 20:24:39 +02:00
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.
This commit is contained in:
@@ -887,6 +887,7 @@ __BIG_ENDIAN__
|
|||||||
__BORLANDC__
|
__BORLANDC__
|
||||||
__CCRX__
|
__CCRX__
|
||||||
__COMPILER_VER__
|
__COMPILER_VER__
|
||||||
|
__COUNTER__
|
||||||
__CYGWIN__
|
__CYGWIN__
|
||||||
__DATE__
|
__DATE__
|
||||||
__DCACHE_PRESENT
|
__DCACHE_PRESENT
|
||||||
|
@@ -1806,8 +1806,8 @@ typedef struct w64wrapper {
|
|||||||
#define PRAGMA_DIAG_POP /* null expansion */
|
#define PRAGMA_DIAG_POP /* null expansion */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define WC_CPP_CAT_(a, b) a ## b
|
#define WC_CPP_CAT4_(a, b, c, d) a ## b ## c ## d
|
||||||
#define WC_CPP_CAT(a, b) WC_CPP_CAT_(a, b)
|
#define WC_CPP_CAT4(a, b, c, d) WC_CPP_CAT4_(a, b, c, d)
|
||||||
#if defined(WC_NO_STATIC_ASSERT)
|
#if defined(WC_NO_STATIC_ASSERT)
|
||||||
#define wc_static_assert(expr) struct wc_static_assert_dummy_struct
|
#define wc_static_assert(expr) struct wc_static_assert_dummy_struct
|
||||||
#define wc_static_assert2(expr, msg) wc_static_assert(expr)
|
#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)
|
#define wc_static_assert2(expr, msg) _Static_assert(expr, msg)
|
||||||
#endif
|
#endif
|
||||||
#else
|
#else
|
||||||
/* C89-compatible fallback */
|
#ifdef __COUNTER__
|
||||||
#define wc_static_assert(expr) \
|
#define wc_static_assert(expr) \
|
||||||
struct WC_CPP_CAT(wc_static_assert_dummy_struct_L, __LINE__) { \
|
struct WC_CPP_CAT4(wc_static_assert_dummy_struct_L, \
|
||||||
|
__LINE__, _, __COUNTER__) { \
|
||||||
char t[(expr) ? 1 : -1]; \
|
char t[(expr) ? 1 : -1]; \
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
#define wc_static_assert(expr) \
|
||||||
|
struct wc_static_assert_dummy_struct
|
||||||
|
#endif
|
||||||
#ifndef wc_static_assert2
|
#ifndef wc_static_assert2
|
||||||
#define wc_static_assert2(expr, msg) wc_static_assert(expr)
|
#define wc_static_assert2(expr, msg) wc_static_assert(expr)
|
||||||
#endif
|
#endif
|
||||||
|
Reference in New Issue
Block a user