Skip to content

Commit 26c0300

Browse files
XenuIsWatchingkartben
authored andcommitted
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 <ryanmcclelland@meta.com>
1 parent f922014 commit 26c0300

File tree

1 file changed

+7
-0
lines changed
  • include/zephyr/drivers

1 file changed

+7
-0
lines changed

include/zephyr/drivers/i3c.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1189,9 +1189,16 @@ struct i3c_driver_config {
11891189

11901190
/** I3C Primary Controller Dynamic Address */
11911191
uint8_t primary_controller_da;
1192+
#elif defined(CONFIG_CPP)
1193+
/* Empty struct has size 0 in C, size 1 in C++. Force them to be the same. */
1194+
uint8_t unused_cpp_size_compatibility;
11921195
#endif
11931196
};
11941197

1198+
#if defined(CONFIG_CPP)
1199+
BUILD_ASSERT(sizeof(struct i3c_driver_config) >= 1);
1200+
#endif
1201+
11951202
/**
11961203
* This structure is common to all I3C drivers and is expected to be the first
11971204
* element in the driver's struct driver_data declaration.

0 commit comments

Comments
 (0)