-
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: adjust the SYS_INIT dev field init to play nice with older comp (alternative to PR68118) #68125
init: adjust the SYS_INIT dev field init to play nice with older comp (alternative to PR68118) #68125
Conversation
Looks like you need to change the commit message, but this fix works for me. Thanks |
Hmm, it seems ARM compiler in SDK is not happy with this version:
|
403c685
to
3aac160
Compare
V2 uploaded:
|
…ilers Fix a build error with certain older Cadence XCC toolchains. These are used e.g. for Intel Tiger Lake products for the audio DSP (thhe oldest platform supported in Zephyr upstream for the audio DSP). To keep all compilers happy, use C89 style initializers. Error: lib/os/p4wq.c:216: error: unknown field ‘dev’ specified in initializer lib/os/p4wq.c:216: warning: missing braces around initializer lib/os/p4wq.c:216: warning: (near initialization for ‘__init_static_init.<anonymous>’) Compiler version XCC RG-2017.8-linux (xt-xcc version 12.0.8) Fixes: 2438dbb ("init: add missing initialization of dev pointer in SYS_INIT macro") Signed-off-by: Kai Vehmanen <[email protected]>
3aac160
to
d3c8f8f
Compare
This is not a toolchain issue. This is because C and C++ are different languages with fairly different designated initializers. Designated initializers were added to C99. They came to C++ 20 years later in https://isocpp.org/files/papers/p0329r0.pdf cc: @nordic-krch |
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 #ifdef __cplusplus to restore them in SYS_INIT_NAMED() thanks to a small braces difference between C and C++. Signed-off-by: Marc Herbert <[email protected]>
Restoring designated initializers in a portable way: EDIT: v2 merged in: Solution thoroughly documented in: |
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 <[email protected]>
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 <[email protected]>
As seen in the PR #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 <[email protected]>
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 <[email protected]>
…ilers
Fix a build error with certain older Cadence XCC toolchains. These are used e.g. for Intel Tiger Lake products for the audio DSP (thhe oldest platform supported in Zephyr upstream for the audio DSP).
Error:
/work/zephyr/lib/os/p4wq.c:216: error: unknown field ‘dev’ specified in initializer /work/zephyr/lib/os/p4wq.c:216: warning: missing braces around initializer /work/zephyr/lib/os/p4wq.c:216: warning: (near initialization for ‘__init_static_init.’)
Compiler version XCC RG-2017.8-linux (xt-xcc version 12.0.8)
Fixes: 2438dbb ("init: add missing initialization of dev pointer in SYS_INIT macro")