File tree Expand file tree Collapse file tree 2 files changed +14
-6
lines changed Expand file tree Collapse file tree 2 files changed +14
-6
lines changed Original file line number Diff line number Diff line change 7777/* * Static Assertion Macro
7878 *
7979 * This macro works from both inside and outside function scope.
80- *
81- * FIXME This is currently not implemented. This issue is tracked at
82- * https://github.com/ARMmbed/uvisor/issues/288
83- */
84- #define UVISOR_STATIC_ASSERT (cond , msg )
80+ * The implementations differ due to compilation differences, C++ static_assert
81+ * is known from C++11 (__cplusplus > 199711L) while mbed-os compiles with c++98,
82+ * and C _Static_assert is known from GCC version 4.6.0. */
83+ #define GCC_VERSION (__GNUC__ * 10000 \
84+ + __GNUC_MINOR__ * 100 \
85+ + __GNUC_PATCHLEVEL__)
86+ #if (__cplusplus > 199711L)
87+ #define UVISOR_STATIC_ASSERT (cond, msg ) static_assert (cond, #msg)
88+ #elif (!__cplusplus && GCC_VERSION > 40600)
89+ #define UVISOR_STATIC_ASSERT (cond, msg ) _Static_assert (cond, #msg)
90+ #else
91+ #define UVISOR_STATIC_ASSERT (cond, msg ) typedef char STATIC_ASSERT_##msg[(cond)?1 :-1 ]
92+ #endif
8593
8694/* convert macro argument to string */
8795/* note: this needs one level of indirection, accomplished with the helper macro
Original file line number Diff line number Diff line change 1- 0ac4c38729d2602bff96d68983a7790143210912
1+ 0fc7c7f55507421463ba46a9692008e87a1ac5f2
You can’t perform that action at this time.
0 commit comments