-
Notifications
You must be signed in to change notification settings - Fork 8.2k
Labels
bugThe issue is a bug, or the PR is fixing a bugThe issue is a bug, or the PR is fixing a bugdev-reviewTo be discussed in dev-review meetingTo be discussed in dev-review meetingplatform: NXPNXPNXPpriority: lowLow impact/importance bugLow impact/importance bug
Description
Describe the bug
It looks like hal_nxp (mcux-sdk code) defines its own ARRAY_SIZE in a public scope, thus polluting the namespace. While it doesn't re-define if already defined, it is still problematic if included before zephyr/sys/util.h, and we should not rely on include order. In some situations, one can observe now:
In file included from ../../../../../../../include/zephyr/devicetree.h:21,
from ../../../../../../../include/zephyr/device.h:12,
from ../../../../../../../include/zephyr/drivers/usb/usb_dc.h:20,
from /__w/zephyr/zephyr/drivers/usb/device/usb_dc_mcux.c:12:
../../../../../../../include/zephyr/sys/util.h:108: error: "ARRAY_SIZE" redefined [-Werror]
108 | #define ARRAY_SIZE(array) \
|
In file included from ../../../../../../../soc/arm/nxp_lpc/lpc55xxx/soc.h:19,
from /__w/zephyr/zephyr/drivers/usb/device/usb_dc_mcux.c:10:
/__w/zephyr/modules/hal/nxp/mcux/mcux-sdk/drivers/common/fsl_common.h:236: note: this is the location of the previous definition
236 | #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
|
cc1: all warnings being treated as errors
[168/181] Building C object zephyr/kernel/CMakeFiles/kernel.dir/sched.c.obj
ninja: build stopped: subcommand failed.
To Reproduce
west build -b lpcxpresso55s69_cpu0 samples/subsys/usb/hid -p
Expected behavior
HAL respects Zephyr ARRAY_SIZE. There are multiple ways to solve this:
- Avoid namespace pollution, e.g. use
FSL_ARRAY_SIZE - Do not expose such method in a "common" public header (possible if only used internally)
- HAL uses Zephyr version when being compiled for Zephyr instead, e.g.
#ifdef __ZEPHYR__
#include <zephyr/sys/util.h>
#else
#define ARRAY_SIZE(x) ...
#endifImpact
Build warnings, CI failures.
Logs and console output
See above.
Environment (please complete the following information):
- OS: Linux
- Toolchain Zephyr SDK 0.15.0
- Commit SHA or Version used 6755999
Additional context
https://github.com/zephyrproject-rtos/zephyr/actions/runs/3272340917/jobs/5383270655
Metadata
Metadata
Assignees
Labels
bugThe issue is a bug, or the PR is fixing a bugThe issue is a bug, or the PR is fixing a bugdev-reviewTo be discussed in dev-review meetingTo be discussed in dev-review meetingplatform: NXPNXPNXPpriority: lowLow impact/importance bugLow impact/importance bug