@@ -77,61 +77,47 @@ do { \
7777 * The assertion acts as a declaration that can be placed at file scope, in a
7878 * code block (except after a label), or as a member of a C++ class/struct/union.
7979 *
80- * @note
81- * Use of MBED_STATIC_ASSERT as a member of a struct/union is limited:
82- * - In C++, MBED_STATIC_ASSERT is valid in class/struct/union scope.
83- * - In C, MBED_STATIC_ASSERT is not valid in struct/union scope, and
84- * MBED_STRUCT_STATIC_ASSERT is provided as an alternative that is valid
85- * in C and C++ class/struct/union scope.
86- *
8780 * @code
88- * MBED_STATIC_ASSERT(MBED_LIBRARY_VERSION >= 120 ,
89- * "The mbed library must be at least version 120 ");
81+ * MBED_STATIC_ASSERT(MBED_MAJOR_VERSION >= 6 ,
82+ * "The mbed-os library must be at least version 6.0.0 ");
9083 *
9184 * int main() {
9285 * MBED_STATIC_ASSERT(sizeof(int) >= sizeof(char),
9386 * "An int must be larger than a char");
9487 * }
9588 * @endcode
89+ *
90+ * @deprecated This feature is now no longer necessary with the minimum
91+ * supported language versions. It will be removed in a forthcoming release.
92+ * Use `static_assert` instead. For C this is provided by `<assert.h>`, and
93+ * for C++ it is a built-in keyword.
9694 */
97- #if defined(__cplusplus) && (__cplusplus >= 201103L || __cpp_static_assert >= 200410L)
98- #define MBED_STATIC_ASSERT (expr, msg ) static_assert (expr, msg)
99- #elif !defined(__cplusplus) && __STDC_VERSION__ >= 201112L
100- #define MBED_STATIC_ASSERT (expr, msg ) _Static_assert (expr, msg)
101- #elif defined(__cplusplus) && defined(__GNUC__) && defined(__GXX_EXPERIMENTAL_CXX0X__) \
102- && (__GNUC__*100 + __GNUC_MINOR__) > 403L
103- #define MBED_STATIC_ASSERT (expr, msg ) __extension__ static_assert (expr, msg)
104- #elif !defined(__cplusplus) && defined(__GNUC__) \
105- && (__GNUC__*100 + __GNUC_MINOR__) > 406L
106- #define MBED_STATIC_ASSERT (expr, msg ) __extension__ _Static_assert (expr, msg)
107- #elif defined(__ICCARM__)
95+ #if defined(__cplusplus )
10896#define MBED_STATIC_ASSERT (expr , msg ) static_assert(expr, msg)
10997#else
110- #define MBED_STATIC_ASSERT (expr, msg ) \
111- enum {MBED_CONCAT (MBED_ASSERTION_AT_, __LINE__) = sizeof (char [(expr) ? 1 : -1 ])}
98+ #define MBED_STATIC_ASSERT (expr , msg ) _Static_assert(expr, msg)
11299#endif
113100
114101/** MBED_STRUCT_STATIC_ASSERT
115102 * Declare compile-time assertions, results in compile-time error if condition is false
116103 *
117- * Unlike MBED_STATIC_ASSERT, MBED_STRUCT_STATIC_ASSERT can and must be used
118- * as a member of a C/C++ class/struct/union.
104+ * Previous supported compiler languages would not allow static_assert to be
105+ * used within a struct or a class. This is no longer the case. This macro
106+ * exists for backwards compatibility.
119107 *
120108 * @code
121109 * struct thing {
122- * MBED_STATIC_ASSERT (2 + 2 == 4,
110+ * MBED_STRUCT_STATIC_ASSERT (2 + 2 == 4,
123111 * "Hopefully the universe is mathematically consistent");
124112 * };
125113 * @endcode
114+ *
115+ * @deprecated This feature is now no longer necessary with the minimum
116+ * supported language versions. It will be removed in a forthcoming release.
117+ * Use `static_assert` instead. For C this is provided by `<assert.h>`, and
118+ * for C++ it is a built-in keyword.
126119 */
127- #if defined(__cplusplus) && (__cplusplus >= 201103L || __cpp_static_assert >= 200410L)
128- #define MBED_STRUCT_STATIC_ASSERT (expr, msg ) static_assert (expr, msg)
129- #elif !defined(__cplusplus) && __STDC_VERSION__ >= 201112L
130- #define MBED_STRUCT_STATIC_ASSERT (expr, msg ) _Static_assert (expr, msg)
131- #else
132- #include < stdbool.h>
133- #define MBED_STRUCT_STATIC_ASSERT (expr, msg ) bool : (expr) ? 0 : -1
134- #endif
120+ #define MBED_STRUCT_STATIC_ASSERT (expr , message ) MBED_STATIC_ASSERT(expr, message)
135121
136122#endif
137123
0 commit comments