Skip to content

Commit 8f89a30

Browse files
committed
MBED_STRUCT_STATIC_ASSERT: Use standard C++11/C11
If available, we can use standard static_assert.
1 parent 7004100 commit 8f89a30

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

platform/mbed_assert.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,13 @@ do { \
125125
* };
126126
* @endcode
127127
*/
128+
#if defined(__cplusplus) && (__cplusplus >= 201103L || __cpp_static_assert >= 200410L)
129+
#define MBED_STRUCT_STATIC_ASSERT(expr, msg) static_assert(expr, msg)
130+
#elif !defined(__cplusplus) && __STDC_VERSION__ >= 201112L
131+
#define MBED_STRUCT_STATIC_ASSERT(expr, msg) _Static_assert(expr, msg)
132+
#else
128133
#define MBED_STRUCT_STATIC_ASSERT(expr, msg) bool : (expr) ? 0 : -1
129-
134+
#endif
130135

131136
#endif
132137

0 commit comments

Comments
 (0)