File tree Expand file tree Collapse file tree 2 files changed +12
-2
lines changed
ports/analog/common-hal/digitalio Expand file tree Collapse file tree 2 files changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -107,7 +107,7 @@ digitalio_direction_t common_hal_digitalio_digitalinout_get_direction(
107
107
108
108
if (self -> pin -> port < 4 ) {
109
109
// Check that I/O mode is enabled and we don't have in AND out on at the same time
110
- MP_STATIC_ASSERT (!((port -> en0 & mask ) && (port -> inen & mask ) && (port -> outen & mask )));
110
+ MP_STATIC_ASSERT_NONCONSTEXPR (!((port -> en0 & mask ) && (port -> inen & mask ) && (port -> outen & mask )));
111
111
112
112
if ((port -> en0 & mask ) && (port -> outen & mask )) {
113
113
return DIRECTION_OUTPUT ;
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 defined(__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 defined(__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