From 26c03005e74ad9942c483c8e71bc624e7a402d03 Mon Sep 17 00:00:00 2001 From: Ryan McClelland Date: Thu, 17 Apr 2025 12:17:48 -0700 Subject: [PATCH] drivers: i3c: fix warning with cpp builds When compiling with C++ enabled (CONFIG_CPP), add an unused member to prevent an empty struct; this makes the struct size the same for both C and C++. Signed-off-by: Ryan McClelland --- include/zephyr/drivers/i3c.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/include/zephyr/drivers/i3c.h b/include/zephyr/drivers/i3c.h index 4e94c890b3b..5d48a360999 100644 --- a/include/zephyr/drivers/i3c.h +++ b/include/zephyr/drivers/i3c.h @@ -1189,9 +1189,16 @@ struct i3c_driver_config { /** I3C Primary Controller Dynamic Address */ uint8_t primary_controller_da; +#elif defined(CONFIG_CPP) + /* Empty struct has size 0 in C, size 1 in C++. Force them to be the same. */ + uint8_t unused_cpp_size_compatibility; #endif }; +#if defined(CONFIG_CPP) +BUILD_ASSERT(sizeof(struct i3c_driver_config) >= 1); +#endif + /** * This structure is common to all I3C drivers and is expected to be the first * element in the driver's struct driver_data declaration.