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

zcbor ARRAY_SIZE conflict with zephyr include #44730

Closed
nordicjm opened this issue Apr 11, 2022 · 3 comments
Closed

zcbor ARRAY_SIZE conflict with zephyr include #44730

nordicjm opened this issue Apr 11, 2022 · 3 comments
Labels
bug The issue is a bug, or the PR is fixing a bug

Comments

@nordicjm
Copy link
Collaborator

Describe the bug
Seen whilst updating a mcumgr PR:

In file included from /tmp/aa/zephyr/include/zephyr/kernel/sched_priq.h:9,
                 from /tmp/aa/zephyr/include/zephyr/kernel_includes.h:23,
                 from /tmp/aa/zephyr/include/zephyr/kernel.h:17,
                 from /tmp/aa/zephyr/include/zephyr/zephyr.h:18,
                 from /tmp/aa/zephyr/subsys/mgmt/mcumgr/lib/cmd/fs_mgmt/include/fs_mgmt/hash_checksum_mgmt.h:11,
                 from /tmp/aa/zephyr/subsys/mgmt/mcumgr/lib/cmd/fs_mgmt/src/hash_checksum_mgmt.c:10:
/tmp/aa/zephyr/include/zephyr/sys/util.h:108: warning: "ARRAY_SIZE" redefined
  108 | #define ARRAY_SIZE(array) \
      | 
In file included from /tmp/aa/zephyr/include/zephyr/mgmt/mcumgr/buf.h:11,
                 from /tmp/aa/zephyr/subsys/mgmt/mcumgr/lib/mgmt/include/mgmt/mgmt.h:11,
                 from /tmp/aa/zephyr/subsys/mgmt/mcumgr/lib/cmd/fs_mgmt/src/hash_checksum_mgmt.c:9:
/tmp/aa/modules/lib/zcbor/include/zcbor_common.h:74: note: this is the location of the previous definition
   74 | #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))

To Reproduce
Build something using both includes

Expected behavior
No warning to be emitted

Impact
Annoyance

Environment (please complete the following information):

  • OS: Linux
  • Toolchain: Zephyr SDK 0.14.0
  • Commit SHA or Version used: Adding commits on top of 70c4841
@nordicjm nordicjm added the bug The issue is a bug, or the PR is fixing a bug label Apr 11, 2022
@de-nordic
Copy link
Collaborator

Reverse order of includes. the zcbor does have #fndef guard, over ARRAY_SIZE definition, that the util.h, from Zephyr, lacks.

@de-nordic
Copy link
Collaborator

I got hit by the same problem, but it is not unique to zcbor as ARRAY_SIZE is now redefined 4 times within modules.

@nordicjm
Copy link
Collaborator Author

Reversing order and adding #include <zephyr.h> to files without it resolves it

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

2 participants