-
Notifications
You must be signed in to change notification settings - Fork 6.8k
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
init.h: restore designated initializers in SYS_INIT_NAMED() v2 #69486
Conversation
Alternative to #69411 recommended by @keith-packard . Only the Some Github workflows EDIT: the re-runs passed. All green now. https://github.com/zephyrproject-rtos/zephyr/actions/runs/8054336494/job/21998974926?pr=69486 This is not specific to this PR, for instance this pure doxygen fix experienced a timeout too: https://github.com/zephyrproject-rtos/zephyr/actions/workflows/twister.yaml EDIT: just found this somewhere:
Reported on discord |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, this should work great. Thanks for the discussion; I learned quite a bit!
@gmarull ping |
include/zephyr/init.h
Outdated
* This Zephyr test compares different C++ -std=... values: | ||
* | ||
* ./scripts/twister -v -b -p qemu_cortex_a53 -T tests/lib/cpp/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please drop CLI snippets from here, maybe just reference the test.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please drop CLI snippets from here, maybe just reference the test.
Done!
Small, pure comment change; @cfriedt can you please re-approve?
As seen in the PR zephyrproject-rtos#68125 discussion, commit 19a33c7 ("init: adjust the SYS_INIT dev field init to play nice with older compilers") entirely threw away designated initializers in SYS_INIT_NAMED() to avoid compatibility issues across toolchains. One key aspect that was probably missed at the time: C and C++ are two different languages and this is especially true with respect to designated initializers. Designated initializers provide safer and more readable code, especially in their much stricter C++ version. So use an #ifdef to restore them in SYS_INIT_NAMED() thanks to a small braces difference between C and C++. Signed-off-by: Marc Herbert <marc.herbert@intel.com>
6131ef9
to
8a7ef84
Compare
As seen in the
PR #68125and #69411 discussions, commit 19a33c7 ("init: adjust the SYS_INIT dev field init to play nice with older compilers") entirely threw away designated initializers in SYS_INIT_NAMED() to avoid compatibility issues across toolchains.One key aspect that was probably missed at the time: C and C++ are two different languages and this is especially true with respect to designated initializers.
Designated initializers provide safer and more readable code, especially in their much stricter C++ version. So use an #ifdef to restore them in SYS_INIT_NAMED() thanks to a small braces difference between C and C++.