From 5c351dc6ae7c20d2ba169d23b0baaa5183f5d723 Mon Sep 17 00:00:00 2001 From: Mikhail Maltsev Date: Thu, 22 Nov 2018 14:43:34 +0000 Subject: [PATCH] Fix C++11 build with Arm Compiler 6 Currently there are two issues which prevent building Mbed OS with -std=gnu++11 when using Arm Compiler 6: * NanostackRfPhys2lp.cpp contains a narrowing conversion in a braced initializer list * ns_types.h includes which Arm Compiler 6 currently does not provide This patch fixes both issues. The first one is fixed by changing the underlying type of the corresponding enumeration when the code is compiled as C++11. The second issue is worked around by avoiding the use of header for Arm Compiler versions prior to 6.12. --- .../802.15.4_RF/stm-s2lp-rf-driver/source/s2lpReg.h | 4 ++++ .../mbed-client-libservice/ns_types.h | 10 +++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/components/802.15.4_RF/stm-s2lp-rf-driver/source/s2lpReg.h b/components/802.15.4_RF/stm-s2lp-rf-driver/source/s2lpReg.h index 1c855d7523..8dbb4a9545 100644 --- a/components/802.15.4_RF/stm-s2lp-rf-driver/source/s2lpReg.h +++ b/components/802.15.4_RF/stm-s2lp-rf-driver/source/s2lpReg.h @@ -301,7 +301,11 @@ typedef enum { S2LP_STATE_SYNTH_SETUP = 0x50 } s2lp_states_e; +#if defined __cplusplus && __cplusplus >= 201103 +typedef enum : uint8_t { +#else typedef enum { +#endif S2LP_CMD_TX = 0x60, S2LP_CMD_RX, S2LP_CMD_READY, diff --git a/features/frameworks/nanostack-libservice/mbed-client-libservice/ns_types.h b/features/frameworks/nanostack-libservice/mbed-client-libservice/ns_types.h index f9b7815b26..f19382a67e 100644 --- a/features/frameworks/nanostack-libservice/mbed-client-libservice/ns_types.h +++ b/features/frameworks/nanostack-libservice/mbed-client-libservice/ns_types.h @@ -121,7 +121,15 @@ typedef int_fast32_t int_fast24_t; #define alignas(n) __align(n) #define __alignas_is_defined 1 #elif (defined __STDC_VERSION__ && __STDC_VERSION__ >= 201112L) || (defined __cplusplus && __cplusplus >= 201103L) -#include +# if defined __ARMCC_VERSION && __ARMCC_VERSION < 6120000 + /* Workaround for Arm Compiler versions prior to 6.12 */ +# if !defined __cplusplus +# define alignas _Alignas +# endif +# define __alignas_is_defined 1 +# else +# include +# endif #elif defined __GNUC__ #define alignas(n) __attribute__((__aligned__(n))) #define __alignas_is_defined 1