Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

util.h: #include zephyr/toolchain.h, not zephyr/toolchain/common.h #62620

Merged
merged 1 commit into from
Sep 14, 2023

Conversation

marc-hb
Copy link
Collaborator

@marc-hb marc-hb commented Sep 14, 2023

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 #62464 by including zephyr/toolchain.h instead, as done by 350 other files.

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

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]>
@marc-hb marc-hb marked this pull request as ready for review September 14, 2023 04:10
@zephyrbot zephyrbot added the area: Base OS Base OS Library (lib/os) label Sep 14, 2023
@marc-hb marc-hb added bug The issue is a bug, or the PR is fixing a bug priority: high High impact/importance bug area: Toolchains Toolchains labels Sep 14, 2023
@fabiobaltieri fabiobaltieri added Hotfix Fix for issues blocking development, i.e. CI issues, tests failing in CI, etc. and removed bug The issue is a bug, or the PR is fixing a bug priority: high High impact/importance bug labels Sep 14, 2023
Copy link
Member

@gmarull gmarull left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

toolchain/ headers should have check that errors if used directly

@fabiobaltieri fabiobaltieri merged commit a654016 into zephyrproject-rtos:main Sep 14, 2023
31 checks passed
@fabiobaltieri
Copy link
Member

toolchain/ headers should have check that errors if used directly

There's quite few of these in the code base, may be worth doing a pass.

@gmarull
Copy link
Member

gmarull commented Sep 14, 2023

toolchain/ headers should have check that errors if used directly

There's quite few of these in the code base, may be worth doing a pass.

@marc-hb marc-hb deleted the util-toolchain-h branch September 14, 2023 23:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: Base OS Base OS Library (lib/os) area: Toolchains Toolchains Hotfix Fix for issues blocking development, i.e. CI issues, tests failing in CI, etc.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants