Skip to content

Commit 510d6a0

Browse files
committed
wolfssl/wolfcrypt/types.h: dial in the __static_assert() gating+definitions, and add static_assert2().
1 parent fbbb2b8 commit 510d6a0

1 file changed

Lines changed: 23 additions & 11 deletions

File tree

wolfssl/wolfcrypt/types.h

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1696,20 +1696,32 @@ typedef struct w64wrapper {
16961696

16971697
#define WC_CPP_CAT_(a, b) a ## b
16981698
#define WC_CPP_CAT(a, b) WC_CPP_CAT_(a, b)
1699-
#ifndef static_assert
1700-
#if !defined(__cplusplus) && !defined(__STRICT_ANSI__) && \
1701-
!defined(WOLF_C89) && ((defined(__GNUC__) && \
1702-
__GNUC__ >= 5) || defined(__clang__))
1703-
#define __static_assert(expr, msg, ...) _Static_assert(expr, msg)
1704-
#define static_assert(expr, ...) \
1705-
__static_assert(expr, ##__VA_ARGS__, #expr)
1706-
#elif defined(__STRICT_ANSI__) || defined(WOLF_C89)
1707-
#define static_assert(expr) \
1708-
struct WC_CPP_CAT(dummy_struct_, __LINE__)
1699+
#if defined(__cplusplus) && (__cplusplus >= 201103L)
1700+
#ifndef static_assert2
1701+
#define static_assert2 static_assert
1702+
#endif
1703+
#elif !defined(static_assert)
1704+
#if !defined(__cplusplus) && \
1705+
!defined(__STRICT_ANSI__) && \
1706+
!defined(WOLF_C89) && \
1707+
defined(__STDC_VERSION__) && \
1708+
(__STDC_VERSION__ >= 201112L) && \
1709+
((defined(__GNUC__) && \
1710+
(__GNUC__ >= 5)) || \
1711+
defined(__clang__))
1712+
#define static_assert(expr) _Static_assert(expr, #expr)
1713+
#ifndef static_assert2
1714+
#define static_assert2(expr, msg) _Static_assert(expr, msg)
1715+
#endif
17091716
#else
1710-
#define static_assert(...) \
1717+
#define static_assert(expr) \
17111718
struct WC_CPP_CAT(wc_dummy_struct_L, __LINE__)
1719+
#ifndef static_assert2
1720+
#define static_assert2(expr, msg) static_assert(expr)
1721+
#endif
17121722
#endif
1723+
#elif !defined(static_assert2)
1724+
#define static_assert2(expr, msg) static_assert(expr)
17131725
#endif
17141726

17151727
#ifndef SAVE_VECTOR_REGISTERS

0 commit comments

Comments
 (0)