Skip to content

Conversation

carlescufi
Copy link
Member

@carlescufi carlescufi commented Oct 6, 2025

C99 has been the minimum required C standard version for Zephyr since its inception. After multiple attempts and discussions, a decision has been made to upgrade to C17 going forward.
This commits replaces the default C standard from C99 to C17 in the configuration and build system.

Closes #97061

@carlescufi
Copy link
Member Author

@stephanosio @nashif @keith-packard should we also enforce C++17 at the same time, for consistency?

Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need to drop these compiler feature flags? This will require all out-of-tree dependencies to drop this (even if they do support an older C standard version?).

I think this can remain, as newer standards should support older flags.

Copy link
Contributor

Choose a reason for hiding this comment

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

good catch.

Yes they should remain, cause they go into a list to tell CMake what standard features are available.
And there we should include old ones.

Some (external) code might do: target_compile_features(foo PRIVATE c_std_99) which is perfectly valid cause that just means code requires feature from c99, which is also supported by c17 (our new default).

@nvetrini
Copy link
Contributor

nvetrini commented Oct 7, 2025

@nashif You may want to consider switching to MISRA C:2012 Amendment 3 as a basis for the guidelines after updating the baseline C standard version, since that edition of the guidelines have much better coverage of C17 than Amendment 2 (e.g. it has guidelines for the safe use of _Generic, which are not present in Amendment 2)

@nashif nashif added the DNM This PR should not be merged (Do Not Merge) label Oct 7, 2025
@nashif
Copy link
Member

nashif commented Oct 7, 2025

DNM until we have verified all prequisites

Copy link
Contributor

@tejlmand tejlmand left a comment

Choose a reason for hiding this comment

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

please keep code in compiler_features.cmake.

The list should still include old standards as that will allow downstream users to request those as required (and it's support when using newer c17 std)

@carlescufi carlescufi requested review from pdgendt and tejlmand October 8, 2025 15:55
@kartben
Copy link
Contributor

kartben commented Oct 8, 2025

a decision has been made to upgrade to C17 going forward.

@carlescufi for tracking purposes, can you please link to the decision in question? I am not questioning that a decision has been made, but I am having a hard time tracking down when/where so I can only imagine it's even harder for mere mortals to find that information.

A few spacing mistakes.

Signed-off-by: Carles Cufi <[email protected]>
C99 has been the minimum required C standard version for Zephyr since
its inception. After multiple attempts and discussions, a decision has
been made to upgrade to C17 going forward.
This commits replaces the default C standard from C99 to C17 in the
configuration and build system.

Signed-off-by: Carles Cufi <[email protected]>
As part of the transition from C99 to C17 as the minimum supported C
standard version, remove the workarounds in the formatted output
subsystem to maintain compatibility with toolchains that do not support
the _Generic keyword.

Signed-off-by: Carles Cufi <[email protected]>
Copy link

@carlescufi
Copy link
Member Author

carlescufi commented Oct 10, 2025

a decision has been made to upgrade to C17 going forward.

@carlescufi for tracking purposes, can you please link to the decision in question? I am not questioning that a decision has been made, but I am having a hard time tracking down when/where so I can only imagine it's even harder for mere mortals to find that information.

It's now linked to in the text of #97061

@nashif nashif added the block: Toolchain Ensure this PR has been tested with non-GCC toolchains label Oct 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: Architectures area: Binary Descriptors area: Build System area: Documentation area: Formatting Output area: Kconfig area: Logging area: Serialization area: Tests Issues related to a particular existing or missing test area: Toolchains Toolchains block: Toolchain Ensure this PR has been tested with non-GCC toolchains DNM This PR should not be merged (Do Not Merge)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Checklist: Transition to C17 as the minimum required C standard version
9 participants