From 28f644b42a32b5d2ca60fa551434013b9fd75909 Mon Sep 17 00:00:00 2001 From: Marc Herbert Date: Thu, 14 Sep 2023 00:49:52 +0000 Subject: [PATCH] util.h: #include zephyr/toolchain.h, not zephyr/toolchain/common.h Commit 9c5dafed95ee ("util: add type checking to CONTAINER_OF") made `util.h` #include `toolchain/common.h` in order to get `BUILD_ASSERT()` used by CONTAINER_OF_VALIDATE() when compiling C code. However `toolchain/common.h` is not supposed to be included directly but indirectly through `toolchain/.h` and in a very specific order. The direct inclusion caused the following warning when compiling C++: ``` toolchain/gcc.h:87: error: "ZRESTRICT" redefined [-Werror] 87 | #define ZRESTRICT __restrict | In file included from include/zephyr/sys/util.h:18: note: this is the location of the previous definition: include/zephyr/toolchain/common.h:33: 33 | #define ZRESTRICT ``` Fix this issue #62464 by including `zephyr/toolchain.h` instead, as done by 350 other files. Fixes commit 9c5dafed95ee ("util: add type checking to CONTAINER_OF") Signed-off-by: Marc Herbert --- include/zephyr/sys/util.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/zephyr/sys/util.h b/include/zephyr/sys/util.h index db5d85eeb41c7c2..29488e23b91033a 100644 --- a/include/zephyr/sys/util.h +++ b/include/zephyr/sys/util.h @@ -15,7 +15,7 @@ #define ZEPHYR_INCLUDE_SYS_UTIL_H_ #include -#include +#include /* needs to be outside _ASMLANGUAGE so 'true' and 'false' can turn * into '1' and '0' for asm or linker scripts