MBED_STRUCT_STATIC_ASSERT - avoid alignment problem

The `int : 0` bitfield this produced could force integer alignment onto
the structure it was placed in, making a structure that should be 1 byte
be 4 bytes.

Change `int` to `bool` to minimise alignment impact - should be to
nothing.

Alignment/size problem was revealed in a `sizeof` check in an
`Atomic<uint8_t>` test.
pull/10837/head
Kevin Bracey 2019-04-01 15:29:19 +03:00
parent 5a8f795976
commit 700410049c
1 changed files with 2 additions and 1 deletions

View File

@ -24,6 +24,7 @@
#ifndef MBED_ASSERT_H
#define MBED_ASSERT_H
#include <stdbool.h>
#include "mbed_preprocessor.h"
#include "mbed_toolchain.h"
@ -124,7 +125,7 @@ do { \
* };
* @endcode
*/
#define MBED_STRUCT_STATIC_ASSERT(expr, msg) int : (expr) ? 0 : -1
#define MBED_STRUCT_STATIC_ASSERT(expr, msg) bool : (expr) ? 0 : -1
#endif