@@ -77,61 +77,47 @@ do { \
77
77
* The assertion acts as a declaration that can be placed at file scope, in a
78
78
* code block (except after a label), or as a member of a C++ class/struct/union.
79
79
*
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
- *
87
80
* @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 ");
90
83
*
91
84
* int main() {
92
85
* MBED_STATIC_ASSERT(sizeof(int) >= sizeof(char),
93
86
* "An int must be larger than a char");
94
87
* }
95
88
* @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.
96
94
*/
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 )
108
96
#define MBED_STATIC_ASSERT (expr , msg ) static_assert(expr, msg)
109
97
#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)
112
99
#endif
113
100
114
101
/** MBED_STRUCT_STATIC_ASSERT
115
102
* Declare compile-time assertions, results in compile-time error if condition is false
116
103
*
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.
119
107
*
120
108
* @code
121
109
* struct thing {
122
- * MBED_STATIC_ASSERT (2 + 2 == 4,
110
+ * MBED_STRUCT_STATIC_ASSERT (2 + 2 == 4,
123
111
* "Hopefully the universe is mathematically consistent");
124
112
* };
125
113
* @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.
126
119
*/
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)
135
121
136
122
#endif
137
123
0 commit comments