Skip to content

Commit 8df1f0a

Browse files
committed
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.
1 parent 3cca002 commit 8df1f0a

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

platform/mbed_assert.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#ifndef MBED_ASSERT_H
2525
#define MBED_ASSERT_H
2626

27+
#include <stdbool.h>
2728
#include "mbed_preprocessor.h"
2829
#include "mbed_toolchain.h"
2930

@@ -124,7 +125,7 @@ do { \
124125
* };
125126
* @endcode
126127
*/
127-
#define MBED_STRUCT_STATIC_ASSERT(expr, msg) int : (expr) ? 0 : -1
128+
#define MBED_STRUCT_STATIC_ASSERT(expr, msg) bool : (expr) ? 0 : -1
128129

129130

130131
#endif

0 commit comments

Comments
 (0)