File tree Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -54,7 +54,14 @@ typedef unsigned int uint;
54
54
#define MP_STRINGIFY (x ) MP_STRINGIFY_HELPER(x)
55
55
56
56
// Static assertion macro
57
+ #if __cplusplus
58
+ #define MP_STATIC_ASSERT (cond ) static_assert((cond), #cond)
59
+ #elif __GNUC__ >= 5 || __STDC_VERSION__ >= 201112L
60
+ #define MP_STATIC_ASSERT (cond ) _Static_assert((cond), #cond)
61
+ #else
57
62
#define MP_STATIC_ASSERT (cond ) ((void)sizeof(char[1 - 2 * !(cond)]))
63
+ #endif
64
+
58
65
// In C++ things like comparing extern const pointers are not constant-expressions so cannot be used
59
66
// in MP_STATIC_ASSERT. Note that not all possible compiler versions will reject this. Some gcc versions
60
67
// do, others only with -Werror=vla, msvc always does.
@@ -63,7 +70,10 @@ typedef unsigned int uint;
63
70
#if defined(_MSC_VER ) || defined(__cplusplus )
64
71
#define MP_STATIC_ASSERT_NONCONSTEXPR (cond ) ((void)1)
65
72
#else
66
- #define MP_STATIC_ASSERT_NONCONSTEXPR (cond ) MP_STATIC_ASSERT(cond)
73
+ #if __clang__
74
+ #pragma GCC diagnostic ignored "-Wgnu-folding-constant"
75
+ #endif
76
+ #define MP_STATIC_ASSERT_NONCONSTEXPR (cond ) ((void)sizeof(char[1 - 2 * !(cond)]))
67
77
#endif
68
78
69
79
// Round-up integer division
You can’t perform that action at this time.
0 commit comments