Skip to content

Commit bbc4cc4

Browse files
committed
treewide: Enforce C17 as the minimum required C standard
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]>
1 parent 8f60b74 commit bbc4cc4

File tree

5 files changed

+9
-78
lines changed

5 files changed

+9
-78
lines changed

CMakeLists.txt

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -319,12 +319,6 @@ if(CONFIG_STD_C23)
319319
set(CSTD c2x)
320320
elseif(CONFIG_STD_C17)
321321
set(CSTD c17)
322-
elseif(CONFIG_STD_C11)
323-
set(CSTD c11)
324-
elseif(CONFIG_STD_C99)
325-
set(CSTD c99)
326-
elseif(CONFIG_STD_C90)
327-
set(CSTD c90)
328322
else()
329323
message(FATAL_ERROR "Unreachable code. Expected C standard to have been chosen.")
330324
endif()

Kconfig.zephyr

Lines changed: 1 addition & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -355,17 +355,6 @@ endmenu
355355

356356
menu "Compiler Options"
357357

358-
config REQUIRES_STD_C99
359-
bool
360-
help
361-
Hidden option to select compiler support C99 standard or higher.
362-
363-
config REQUIRES_STD_C11
364-
bool
365-
select REQUIRES_STD_C99
366-
help
367-
Hidden option to select compiler support C11 standard or higher.
368-
369358
config REQUIRES_STD_C17
370359
bool
371360
select REQUIRES_STD_C11
@@ -381,31 +370,10 @@ config REQUIRES_STD_C23
381370
choice STD_C
382371
prompt "C Standard"
383372
default STD_C23 if REQUIRES_STD_C23
384-
default STD_C17 if REQUIRES_STD_C17
385-
default STD_C11 if REQUIRES_STD_C11
386-
default STD_C99
373+
default STD_C17
387374
help
388375
C Standards.
389376

390-
config STD_C90
391-
bool "C90"
392-
depends on !REQUIRES_STD_C99
393-
help
394-
1989 C standard as completed in 1989 and ratified by ISO/IEC
395-
as ISO/IEC 9899:1990. This version is known as "ANSI C".
396-
397-
config STD_C99
398-
bool "C99"
399-
depends on !REQUIRES_STD_C11
400-
help
401-
1999 C standard.
402-
403-
config STD_C11
404-
bool "C11"
405-
depends on !REQUIRES_STD_C17
406-
help
407-
2011 C standard.
408-
409377
config STD_C17
410378
bool "C17"
411379
depends on !REQUIRES_STD_C23

cmake/compiler/compiler_features.cmake

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,15 @@
1-
set(c23id c2x gnu2x)
1+
set(c23id c2x gnu2x "iso9899:2023" "iso9899:2024")
22
set(c17id c17 c18 gnu17 gnu18 "iso9899:2017" "iso9899:2018")
3-
set(c11id c11 gnu11 "iso9899:2011")
4-
set(c99id c99 gnu99 "iso9899:1999")
5-
set(c90id c89 c90 gnu89 gnu90 "iso9899:1990" "iso9899:199409")
63

74
set(compile_features_list)
85

96
# For each id value above a compile_features_${idval} with a list of supported
107
# `c_std_XX` values are created for easy lookup.
118
# For example, the settings
12-
# - `compile_feature_c99` will contain `c_std_90;c_std_99`
13-
# - `compile_feature_iso9899:2011` will contain `c_std_90;c_std_99;c_std_11`
9+
# - `compile_feature_c23` will contain `c_std_17;c_std_23`
10+
# - `compile_feature_iso9899:2023` will contain `c_std_17;c_std_23`
1411
# that can then be used to set CMAKE_C_COMPILE_FEATURES accordingly.
15-
foreach(standard 90 99 11 17 23)
12+
foreach(standard 17 23)
1613
list(APPEND compile_features_list c_std_${standard})
1714
foreach(id ${c${standard}id})
1815
set(compile_features_${id} ${compile_features_list})

tests/subsys/bindesc/definition/testcase.yaml

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -19,24 +19,10 @@ tests:
1919
- qemu_riscv32
2020
- qemu_riscv32e
2121
- qemu_riscv64
22-
bindesc.define.c99:
23-
extra_configs:
24-
- CONFIG_STD_C99=y
25-
bindesc.define.c11:
26-
extra_configs:
27-
- CONFIG_STD_C11=y
28-
bindesc.define.c17:
22+
bindesc.define.c17:
2923
extra_configs:
3024
- CONFIG_STD_C17=y
31-
bindesc.define.gnu99:
32-
extra_configs:
33-
- CONFIG_STD_C99=y
34-
- CONFIG_GNU_C_EXTENSIONS=y
35-
bindesc.define.gnu11:
36-
extra_configs:
37-
- CONFIG_STD_C11=y
38-
- CONFIG_GNU_C_EXTENSIONS=y
39-
bindesc.define.gnu17:
25+
bindesc.define.gnu17:
4026
extra_configs:
4127
- CONFIG_STD_C17=y
4228
- CONFIG_GNU_C_EXTENSIONS=y

tests/subsys/bindesc/reading/testcase.yaml

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,24 +8,10 @@ tests:
88
bindesc.read:
99
platform_allow:
1010
- native_sim
11-
bindesc.read.c99:
12-
extra_configs:
13-
- CONFIG_STD_C99=y
14-
bindesc.read.c11:
15-
extra_configs:
16-
- CONFIG_STD_C11=y
17-
bindesc.read.c17:
11+
bindesc.read.c17:
1812
extra_configs:
1913
- CONFIG_STD_C17=y
20-
bindesc.read.gnu99:
21-
extra_configs:
22-
- CONFIG_STD_C99=y
23-
- CONFIG_GNU_C_EXTENSIONS=y
24-
bindesc.read.gnu11:
25-
extra_configs:
26-
- CONFIG_STD_C11=y
27-
- CONFIG_GNU_C_EXTENSIONS=y
28-
bindesc.read.gnu17:
14+
bindesc.read.gnu17:
2915
extra_configs:
3016
- CONFIG_STD_C17=y
3117
- CONFIG_GNU_C_EXTENSIONS=y

0 commit comments

Comments
 (0)