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

Unable to use LOG_BACKEND_DEFINE macro from log_backend.h using C++ #22482

Closed
glenne opened this issue Feb 5, 2020 · 1 comment
Closed

Unable to use LOG_BACKEND_DEFINE macro from log_backend.h using C++ #22482

glenne opened this issue Feb 5, 2020 · 1 comment
Labels
bug The issue is a bug, or the PR is fixing a bug

Comments

@glenne
Copy link
Contributor

glenne commented Feb 5, 2020

Describe the bug
When including log_backend.h from a C++ application, the following error is produced by the C++ compiler:

zephyr/include/logging/log_backend.h:81:2: error: designator order for field 'log_backend_control_block::id' does not match declaration order in 'log_backend_control_block'

To Reproduce
Steps to reproduce the behavior:

  1. Add the following code to a C++ source file

#include <logging/log_backend.h> const struct log_backend_api my_backend_api = {}; LOG_BACKEND_DEFINE(my_backend, my_backend_api, true);
Expected behavior
A compilation error is not produced.

Impact
Annoyance. A workaround is to #undef the macro and redefine it with correct order of arguments.

Fix
The fix is to reverse the order of the .id and .active initialization lines in the LOG_BACKEND_DEFINE macro.

Environment (please complete the following information):

  • OS: Fedora
  • Toolchain Zephyr riscv SDK
  • Commit SHA 4fea711
@glenne glenne added the bug The issue is a bug, or the PR is fixing a bug label Feb 5, 2020
@glenne glenne changed the title Unable to LOG_BACKEND_DEFINE macro from log_backend.h using C++ Unable to use LOG_BACKEND_DEFINE macro from log_backend.h using C++ Feb 5, 2020
@glenne
Copy link
Contributor Author

glenne commented Feb 5, 2020

Fix is in pull request - #22483

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug The issue is a bug, or the PR is fixing a bug
Projects
None yet
Development

No branches or pull requests

1 participant