Skip to content

Commit

Permalink
util.h: #include zephyr/toolchain.h, not zephyr/toolchain/common.h
Browse files Browse the repository at this point in the history
Commit 9c5dafe ("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/<your_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 zephyrproject-rtos#62464 by including `zephyr/toolchain.h` instead, as done
by 350 other files.

Fixes commit 9c5dafe ("util: add type checking to CONTAINER_OF")

Signed-off-by: Marc Herbert <[email protected]>
  • Loading branch information
marc-hb authored and fabiobaltieri committed Sep 14, 2023
1 parent 7b8b562 commit a654016
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion include/zephyr/sys/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#define ZEPHYR_INCLUDE_SYS_UTIL_H_

#include <zephyr/sys/util_macro.h>
#include <zephyr/toolchain/common.h>
#include <zephyr/toolchain.h>

/* needs to be outside _ASMLANGUAGE so 'true' and 'false' can turn
* into '1' and '0' for asm or linker scripts
Expand Down

0 comments on commit a654016

Please sign in to comment.