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

device.h: fix inconsistent semicolon logic for DEVICE_DT_DEFINE #79279

Merged

Conversation

pillo79
Copy link
Collaborator

@pillo79 pillo79 commented Oct 1, 2024

PR #78508 added optional export of DT devices in the DEVICE_DT_DEFINE macro, but created inconsistent semicolon semantics:

  • When CONFIG_LLEXT_EXPORT_DEVICES is not enabled, the DEVICE_DT_DEFINE macro ends (as it was before the PR) with the contents of the Z_DEVICE_DEFINE macro, which always include a terminating semicolon.

  • When CONFIG_LLEXT_EXPORT_DEVICES is enabled, the macro ends with Z_DEVICE_EXPORT, which ultimately maps to Z_EXPORT_SYMBOL and does not include a terminating semicolon. This leads to a syntax error in places where the DEVICE_DT_DEFINE macro is used without it, like here.

Fix this by adjusting the code added when CONFIG_LLEXT_EXPORT_DEVICES is enabled to include a semicolon after the Z_DEVICE_EXPORT macro; also remove a stray backslash that was added in the same PR.

When CONFIG_LLEXT_EXPORT_DEVICES is not enabled, the DEVICE_DT_DEFINE
macro ends with the contents of the Z_DEVICE_DEFINE macro, which always
includes a terminating semicolon.

When CONFIG_LLEXT_EXPORT_DEVICES is enabled, the macro ends with
Z_DEVICE_EXPORT, which does _not_ include a terminating semicolon. This
leads to a syntax error in places where the DEVICE_DT_DEFINE macro is
used without it.

Fix this by adjusting the added code when CONFIG_LLEXT_EXPORT_DEVICES is
enabled to include a semicolon after the Z_DEVICE_EXPORT macro; also use
the opportunity to remove a stray backslash.

Signed-off-by: Luca Burelli <l.burelli@arduino.cc>
@pillo79 pillo79 added the size: XS A PR changing only a single line of code label Oct 1, 2024
@pillo79 pillo79 marked this pull request as ready for review October 2, 2024 08:16
@fabiobaltieri fabiobaltieri merged commit 17be7ff into zephyrproject-rtos:main Oct 4, 2024
29 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: Device Model size: XS A PR changing only a single line of code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants