Skip to content

logging: logging void * does not work when compiling with clang++ #87308

Open
rysiof/zephyr
#1
@rysiof

Description

@rysiof

Describe the bug

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++

To Reproduce
Add LOG_WRN("%p", (void *)str); to c++ code and compile with clang++

Expected behavior
No errors

Impact
Impacts C++ code compiled with clang++ code, for example Xtensa targets with RJ-2024.3 toolchain

Logs and console output

Environment (please complete the following information):
All

Additional context

Metadata

Metadata

Assignees

Labels

area: LoggingbugThe issue is a bug, or the PR is fixing a bugpriority: lowLow impact/importance bug

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions