Skip to content

Commit e4b4539

Browse files
authored
Merge pull request #10837 from kjbracey-arm/toolchain11
Toolchain attributes - use C++11/C11
2 parents 2dc562f + 703af8d commit e4b4539

File tree

2 files changed

+18
-4
lines changed

2 files changed

+18
-4
lines changed

platform/mbed_assert.h

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,14 @@ do { \
124124
* };
125125
* @endcode
126126
*/
127-
#define MBED_STRUCT_STATIC_ASSERT(expr, msg) int : (expr) ? 0 : -1
128-
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
129135

130136
#endif
131137

platform/mbed_toolchain.h

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,11 @@
7272
* @endcode
7373
*/
7474
#ifndef MBED_ALIGN
75-
#if defined(__ICCARM__)
75+
#if __cplusplus >= 201103 && !defined __CC_ARM
76+
#define MBED_ALIGN(N) alignas(N)
77+
#elif __STDC_VERSION__ >= 201112 && !defined __CC_ARM
78+
#define MBED_ALIGN(N) _Alignas(N)
79+
#elif defined(__ICCARM__)
7680
#define MBED_ALIGN(N) _Pragma(MBED_STRINGIFY(data_alignment=N))
7781
#else
7882
#define MBED_ALIGN(N) __attribute__((aligned(N)))
@@ -298,7 +302,11 @@
298302
* @endcode
299303
*/
300304
#ifndef MBED_NORETURN
301-
#if defined(__GNUC__) || defined(__clang__) || defined(__CC_ARM)
305+
#if __cplusplus >= 201103
306+
#define MBED_NORETURN [[noreturn]]
307+
#elif __STDC_VERSION__ >= 201112
308+
#define MBED_NORETURN _Noreturn
309+
#elif defined(__GNUC__) || defined(__clang__) || defined(__CC_ARM)
302310
#define MBED_NORETURN __attribute__((noreturn))
303311
#elif defined(__ICCARM__)
304312
#define MBED_NORETURN __noreturn

0 commit comments

Comments
 (0)