Merge pull request #10837 from kjbracey-arm/toolchain11

Toolchain attributes - use C++11/C11
pull/10964/head
Martin Kojtal 2019-07-04 15:35:29 +01:00 committed by GitHub
commit e4b4539d27
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 4 deletions

View File

@ -124,8 +124,14 @@ do { \
* }; * };
* @endcode * @endcode
*/ */
#define MBED_STRUCT_STATIC_ASSERT(expr, msg) int : (expr) ? 0 : -1 #if defined(__cplusplus) && (__cplusplus >= 201103L || __cpp_static_assert >= 200410L)
#define MBED_STRUCT_STATIC_ASSERT(expr, msg) static_assert(expr, msg)
#elif !defined(__cplusplus) && __STDC_VERSION__ >= 201112L
#define MBED_STRUCT_STATIC_ASSERT(expr, msg) _Static_assert(expr, msg)
#else
#include <stdbool.h>
#define MBED_STRUCT_STATIC_ASSERT(expr, msg) bool : (expr) ? 0 : -1
#endif
#endif #endif

View File

@ -72,7 +72,11 @@
* @endcode * @endcode
*/ */
#ifndef MBED_ALIGN #ifndef MBED_ALIGN
#if defined(__ICCARM__) #if __cplusplus >= 201103 && !defined __CC_ARM
#define MBED_ALIGN(N) alignas(N)
#elif __STDC_VERSION__ >= 201112 && !defined __CC_ARM
#define MBED_ALIGN(N) _Alignas(N)
#elif defined(__ICCARM__)
#define MBED_ALIGN(N) _Pragma(MBED_STRINGIFY(data_alignment=N)) #define MBED_ALIGN(N) _Pragma(MBED_STRINGIFY(data_alignment=N))
#else #else
#define MBED_ALIGN(N) __attribute__((aligned(N))) #define MBED_ALIGN(N) __attribute__((aligned(N)))
@ -298,7 +302,11 @@
* @endcode * @endcode
*/ */
#ifndef MBED_NORETURN #ifndef MBED_NORETURN
#if defined(__GNUC__) || defined(__clang__) || defined(__CC_ARM) #if __cplusplus >= 201103
#define MBED_NORETURN [[noreturn]]
#elif __STDC_VERSION__ >= 201112
#define MBED_NORETURN _Noreturn
#elif defined(__GNUC__) || defined(__clang__) || defined(__CC_ARM)
#define MBED_NORETURN __attribute__((noreturn)) #define MBED_NORETURN __attribute__((noreturn))
#elif defined(__ICCARM__) #elif defined(__ICCARM__)
#define MBED_NORETURN __noreturn #define MBED_NORETURN __noreturn