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

log_core.h error on pointer-to-int-cast on 64bit system #10423

Closed
b0661 opened this issue Oct 8, 2018 · 3 comments
Closed

log_core.h error on pointer-to-int-cast on 64bit system #10423

b0661 opened this issue Oct 8, 2018 · 3 comments
Assignees
Labels
area: Logging Enhancement Changes/Updates/Additions to existing features

Comments

@b0661
Copy link
Collaborator

b0661 commented Oct 8, 2018

I´m running an unit test on a 64bit system. The module under test has some logging macros included.

The logging macro tries to cast pointers to u32_t values. This does not work on my system.

The cast should follow the compiler´s pointer size.

...sanity-out/unit_testing/tests/unit/drivers/pinctrl/test/main.c:712:3: note: in expansion of macro ‘LOG_ERR’
   LOG_ERR("Invalid pin %d of %s on mux free by %s.",
   ^~~~~~~
...include/logging/log_core.h:147:46: error: cast from pointer to integer of different size [-Werror=pointer-to-int-cast]
  log_3(_str, (u32_t)(_arg0), (u32_t)(_arg1), (u32_t)(_arg2), _src_level)
                                              ^

@nordic-krch
Copy link
Contributor

arguments in log message are 32bit width so it will not work in 64bit system, they must be casted. You need to compile unit test in 32 bits. We might in future extend the logger to have argument size according to architecture but there are many other issues pending in the queue so it is rather a long term goal.

@b0661
Copy link
Collaborator Author

b0661 commented Oct 8, 2018

@nordic-krch

Is there a way I can prevent the logger macros to generate C code at all?

@nordic-krch
Copy link
Contributor

@b0661 unfortunately, no. Macros were intentionally created in that way to always create code even though it's later on removed during compilation.

@nashif nashif added the bug The issue is a bug, or the PR is fixing a bug label Oct 9, 2018
@nashif nashif added the priority: medium Medium impact/importance bug label Oct 11, 2018
@nashif nashif added Enhancement Changes/Updates/Additions to existing features and removed bug The issue is a bug, or the PR is fixing a bug priority: medium Medium impact/importance bug labels Mar 5, 2019
@b0661 b0661 closed this as completed Feb 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: Logging Enhancement Changes/Updates/Additions to existing features
Projects
None yet
Development

No branches or pull requests

4 participants