Skip to content

Commit 5c351dc

Browse files
committed
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 <stdalign.h> 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 <stdalign.h> header for Arm Compiler versions prior to 6.12.
1 parent 60b5547 commit 5c351dc

File tree

2 files changed

+13
-1
lines changed
  • components/802.15.4_RF/stm-s2lp-rf-driver/source
  • features/frameworks/nanostack-libservice/mbed-client-libservice

2 files changed

+13
-1
lines changed

components/802.15.4_RF/stm-s2lp-rf-driver/source/s2lpReg.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,11 @@ typedef enum {
301301
S2LP_STATE_SYNTH_SETUP = 0x50
302302
} s2lp_states_e;
303303

304+
#if defined __cplusplus && __cplusplus >= 201103
305+
typedef enum : uint8_t {
306+
#else
304307
typedef enum {
308+
#endif
305309
S2LP_CMD_TX = 0x60,
306310
S2LP_CMD_RX,
307311
S2LP_CMD_READY,

features/frameworks/nanostack-libservice/mbed-client-libservice/ns_types.h

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,15 @@ typedef int_fast32_t int_fast24_t;
121121
#define alignas(n) __align(n)
122122
#define __alignas_is_defined 1
123123
#elif (defined __STDC_VERSION__ && __STDC_VERSION__ >= 201112L) || (defined __cplusplus && __cplusplus >= 201103L)
124-
#include <stdalign.h>
124+
# if defined __ARMCC_VERSION && __ARMCC_VERSION < 6120000
125+
/* Workaround for Arm Compiler versions prior to 6.12 */
126+
# if !defined __cplusplus
127+
# define alignas _Alignas
128+
# endif
129+
# define __alignas_is_defined 1
130+
# else
131+
# include <stdalign.h>
132+
# endif
125133
#elif defined __GNUC__
126134
#define alignas(n) __attribute__((__aligned__(n)))
127135
#define __alignas_is_defined 1

0 commit comments

Comments
 (0)