From 700410049c40d3414af6842bf9f87e7110f3e771 Mon Sep 17 00:00:00 2001 From: Kevin Bracey Date: Mon, 1 Apr 2019 15:29:19 +0300 Subject: [PATCH] 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` test. --- platform/mbed_assert.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/platform/mbed_assert.h b/platform/mbed_assert.h index a748f3aceb..a9bbc8c696 100644 --- a/platform/mbed_assert.h +++ b/platform/mbed_assert.h @@ -24,6 +24,7 @@ #ifndef MBED_ASSERT_H #define MBED_ASSERT_H +#include #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