Skip to content

logging: Fix compilation errors with clang++ when printing void* #1

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

rysiof
Copy link
Owner

@rysiof rysiof commented Mar 18, 2025

https://docs.zephyrproject.org/latest/services/logging/index.html#recommendations recommends to cast arguments logged with %p to void *, and it works fine with gcc, g++ and clang. however with clang++ it causes error that cannot be suppressed: error: arithmetic on a pointer to void.

It is because we are using (arg) + 0 inside _Generic to workaround issues with _Generic and bit fields. https://gcc.gnu.org/legacy-ml/gcc/2016-02/msg00266.html suggests to use different syntax: 0:(arg):(arg). This seems to be working with gcc, g++, clang and clang++

Fixes: zephyrproject-rtos#87308

Signed-off-by: Maciej Kusio [email protected]

https://docs.zephyrproject.org/latest/services/logging/index.html#recommendations recommends to cast arguments logged with %p to void *, and it works fine with gcc, g++ and clang. however with clang++ it causes error that cannot be suppressed: error: arithmetic on a pointer to void.

It is because we are using (arg) + 0 inside _Generic to workaround issues with _Generic and bit fields.
https://gcc.gnu.org/legacy-ml/gcc/2016-02/msg00266.html suggests to use different syntax: 0:(arg):(arg). This seems to be working with gcc, g++, clang and clang++

Fixes: zephyrproject-rtos#87308

Signed-off-by: Maciej Kusio <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

logging: logging void * does not work when compiling with clang++
1 participant