Skip to content

Toolchain attributes - use C++11/C11 #10837

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jul 4, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions platform/mbed_assert.h
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,14 @@ do { \
* };
* @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

Expand Down
12 changes: 10 additions & 2 deletions platform/mbed_toolchain.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,11 @@
* @endcode
*/
#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))
#else
#define MBED_ALIGN(N) __attribute__((aligned(N)))
Expand Down Expand Up @@ -298,7 +302,11 @@
* @endcode
*/
#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))
#elif defined(__ICCARM__)
#define MBED_NORETURN __noreturn
Expand Down