kconfig: Add symbols for C standard

Add symbols to select a C standard. Next to an option, hidden symbols
are available to select the minimum.
This allows subsystems or modules to select the least compliant C
standard supported.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
This commit is contained in:
Pieter De Gendt 2024-04-03 09:32:10 +02:00 committed by Fabio Baltieri
commit 86b721c45e
2 changed files with 83 additions and 1 deletions

View file

@ -957,7 +957,24 @@ if(CONFIG_USERSPACE)
endif()
get_property(CSTD GLOBAL PROPERTY CSTD)
set_ifndef(CSTD c99)
if(NOT DEFINED CSTD)
if(CONFIG_STD_C23)
set(CSTD c2x)
elseif(CONFIG_STD_C17)
set(CSTD c17)
elseif(CONFIG_STD_C11)
set(CSTD c11)
elseif(CONFIG_STD_C99)
set(CSTD c99)
elseif(CONFIG_STD_C90)
set(CSTD c90)
else()
message(FATAL_ERROR "Unreachable code. Expected C standard to have been chosen.")
endif()
else()
message(DEPRECATION
"Global CSTD property is deprecated, see Kconfig.zephyr for C Standard options.")
endif()
# @Intent: Obtain compiler specific flag for specifying the c standard
zephyr_compile_options(