How can i use a newer c standard (c11 or c17) when compiling my zephyr application

I like to enable compiling my code with c11 or c17 but when compiling with west this does not seem to be possible.

To force the compiler to use c11, I used option:

CONFIG_COMPILER_OPT="-std=c11"

However, this is overruled in the build, as can be seen in compile_commands.json:

/home/maarten/ncs/toolchains/v2.1.0/opt/zephyr-sdk/arm-zephyr-eabi/bin/arm-zephyr-eabi-gcc -DEXT_API_MAGIC=0x281ee6de,0xb845acea,23298 -DFIRMWARE_INFO_MAGIC=0x281ee6de,0x8fcebb4c,23298 -DKERNEL -DMBEDTLS_CONFIG_FILE=\\\"nrf-config.h\\\" -DMBEDTLS_USER_CONFIG_FILE=\\\"nrf-config-user.h\\\" -DNRF9160_XXAA -DNRF_SKIP_FICR_NS_COPY_TO_RAM -DNRF_TRUSTZONE_NONSECURE -DTFM_PSA_API -DUSE_PARTITION_MANAGER=1 -DVALIDATION_INFO_MAGIC=0x281ee6de,0x86518483,88834 -DVALIDATION_POINTER_MAGIC=0x281ee6de,0x6919b47e,88834 -D_FORTIFY_SOURCE=2 -D__LINUX_ERRNO_EXTENSIONS__ -D__PROGRAM_START -D__ZEPHYR__=1 -I/home/maarten/ncs/v2.1.0/zephyr/include/zephyr -I/home/maarten/ncs/v2.1.0/zephyr/include -I/home/maarten/workspace/avic/fw/spikes/legiobox/blinky_fota/build/release/zephyr/include/generated -I/home/maarten/ncs/v2.1.0/zephyr/soc/arm/nordic_nrf/nrf91 -I/home/maarten/ncs/v2.1.0/zephyr/lib/libc/newlib/include -I/home/maarten/ncs/v2.1.0/zephyr/soc/arm/nordic_nrf/common/. -I/home/maarten/ncs/v2.1.0/zephyr/subsys/net/lib/sockets/. -I/home/maarten/ncs/v2.1.0/nrf/include -I/home/maarten/ncs/v2.1.0/nrf/lib/at_cmd_parser/include -I/home/maarten/ncs/v2.1.0/nrf/subsys/net/lib/fota_download/./include -I/home/maarten/ncs/v2.1.0/zephyr/../nrf/subsys/dfu/include -I/home/maarten/ncs/v2.1.0/nrf/include/tfm -I/home/maarten/workspace/avic/fw/spikes/legiobox/blinky_fota/build/release/tfm/generated/interface/include -I/home/maarten/ncs/v2.1.0/modules/hal/cmsis/CMSIS/Core/Include -I/home/maarten/ncs/v2.1.0/modules/hal/nordic/nrfx -I/home/maarten/ncs/v2.1.0/modules/hal/nordic/nrfx/drivers/include -I/home/maarten/ncs/v2.1.0/modules/hal/nordic/nrfx/mdk -I/home/maarten/ncs/v2.1.0/zephyr/modules/hal_nordic/nrfx/. -I/home/maarten/ncs/v2.1.0/modules/lib/zcbor/include -I/home/maarten/ncs/v2.1.0/nrfxlib/nrf_modem/include -I/home/maarten/workspace/avic/fw/spikes/legiobox/blinky_fota/build/release/tfm/install/interface/include -I/home/maarten/workspace/avic/fw/spikes/legiobox/blinky_fota/build/release/modules/nrfxlib/nrfxlib/nrf_security/src/include/generated -I/home/maarten/ncs/v2.1.0/nrfxlib/nrf_security/include -I/home/maarten/ncs/v2.1.0/nrfxlib/nrf_security/include/mbedtls -I/home/maarten/ncs/v2.1.0/mbedtls/include -I/home/maarten/ncs/v2.1.0/mbedtls/include/mbedtls -I/home/maarten/ncs/v2.1.0/mbedtls/include/psa -I/home/maarten/ncs/v2.1.0/mbedtls/library -I/home/maarten/ncs/v2.1.0/nrfxlib/crypto/nrf_oberon/include/mbedtls -I/home/maarten/ncs/v2.1.0/nrfxlib/crypto/nrf_oberon/include -Os -imacros /home/maarten/workspace/avic/fw/spikes/legiobox/blinky_fota/build/release/zephyr/include/generated/autoconf.h -ffreestanding -fno-common -g -gdwarf-4 -fdiagnostics-color=always -mcpu=cortex-m33 -mthumb -mabi=aapcs -mfp16-format=ieee --sysroot=/home/maarten/ncs/toolchains/v2.1.0/opt/zephyr-sdk/arm-zephyr-eabi/arm-zephyr-eabi -imacros /home/maarten/ncs/v2.1.0/zephyr/include/zephyr/toolchain/zephyr_stdint.h -Wall -Wformat -Wformat-security -Wno-format-zero-length -Wno-main -Wno-pointer-sign -Wpointer-arith -Wexpansion-to-defined -Wno-unused-but-set-variable -Werror=implicit-int -fno-asynchronous-unwind-tables -fno-pie -fno-pic -std=c11 -fno-reorder-functions -fno-defer-pop -fmacro-prefix-map=/home/maarten/workspace/avic/fw/spikes/legiobox/blinky_fota=CMAKE_SOURCE_DIR -fmacro-prefix-map=/home/maarten/ncs/v2.1.0/zephyr=ZEPHYR_BASE -fmacro-prefix-map=/home/maarten/ncs/v2.1.0=WEST_TOPDIR -ffunction-sections -fdata-sections -specs=nano.specs -std=c99 -o CMakeFiles/app.dir/src/main.c.obj -c /home/maarten/workspace/avic/fw/spikes/legiobox/blinky_fota/src/main.c"

Question: What is the proper way of changing the used c-standard for the application files?

Question: Can the used c-standard be configured for the application files only (and not for the zephyr source files)?

Parents Reply Children
No Data
Related