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.
pull/8843/head
Mikhail Maltsev 2018-11-22 14:43:34 +00:00
parent 60b5547b65
commit 5c351dc6ae
2 changed files with 13 additions and 1 deletions

View File

@ -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,

View File

@ -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)
# 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 <stdalign.h>
# endif
#elif defined __GNUC__
#define alignas(n) __attribute__((__aligned__(n)))
#define __alignas_is_defined 1