mirror of https://github.com/ARMmbed/mbed-os.git
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
parent
5a8f795976
commit
700410049c
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in New Issue