Skip to content

device: Update SYS_INIT_NAMED(), Z_DEVICE_INIT_ENTRY_DEFINE() to be C++ compatible #86957

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

Merged
merged 2 commits into from
Mar 13, 2025

Conversation

tristan-google
Copy link
Collaborator

@tristan-google tristan-google commented Mar 11, 2025

In #84394, struct init_entry was modified to remove an unneeded union. The SYS_INIT_NAMED() macro was adjusted accordingly, but is no longer C++ compatible due to the partial designated initializer.

Add an explicit value (NULL) for the other field (dev) in that struct.

Additional change (second commit): the Z_DEVICE_INIT_ENTRY_DEFINE() macro uses a designated initializer to define a struct. Ensure all members of struct init_entry are defined in order for C++ compatibility.

@tristan-google tristan-google requested a review from yperess March 11, 2025 20:49
@tristan-google tristan-google added the Hotfix Fix for issues blocking development, i.e. CI issues, tests failing in CI, etc. label Mar 11, 2025
yperess
yperess previously approved these changes Mar 11, 2025
@tristan-google tristan-google changed the title Update SYS_INIT_NAMED() to be C++ compatible device: Update SYS_INIT_NAMED() to be C++ compatible Mar 11, 2025
Comment on lines 167 to 168
static const Z_DECL_ALIGN(struct init_entry) Z_INIT_ENTRY_SECTION(level, prio, 0) \
__used __noasan \
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this need to reformat these two lines? Conventionally you'd avoid that.

@fabiobaltieri
Copy link
Member

Feels like we are going in circles with this one:

Shouldn't c++ tests catch this? At least in the push run.

Copy link
Member

@gmarull gmarull left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please remove stray formatting changes, otherwise lgtm

In zephyrproject-rtos#84394, `struct init_entry` was modified to remove an unneeded union.
The `SYS_INIT_NAMED()` macro was adjusted accordingly, but is no longer
C++ compatible due to the partial designated initializer.

Add an explicit value (NULL) for the other field (`dev`) in that struct.

Signed-off-by: Tristan Honscheid <[email protected]>
The `Z_DEVICE_INIT_ENTRY_DEFINE()` macro uses a designated initializer
to define a struct. Ensure all members of `struct init_entry` are
defined in order for C++ compatibility.

Signed-off-by: Tristan Honscheid <[email protected]>
@tristan-google tristan-google changed the title device: Update SYS_INIT_NAMED() to be C++ compatible device: Update SYS_INIT_NAMED(), Z_DEVICE_INIT_ENTRY_DEFINE() to be C++ compatible Mar 12, 2025
@tristan-google tristan-google requested a review from gmarull March 12, 2025 18:14
@kartben kartben merged commit aa240e2 into zephyrproject-rtos:main Mar 13, 2025
23 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: C++ area: Device Model Hotfix Fix for issues blocking development, i.e. CI issues, tests failing in CI, etc.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants