Re: how to change the compiler from C99 to gnu99 #std


Kumar Gala
 

On May 14, 2020, at 10:29 AM, Stefan Hristozov <stefan.hristozov@...> wrote:

Hi,

I want to change the compiler from c99 to gnu99.
I have tried to set CONFIG_COMPILER_OPT="-std=gnu99" in my prj.conf file. Unfortunately this does not remove -std=c99, see e.g. a single line of my compiler output:

[9/169] ccache /home/stefan/zephyr-sdk-0.11.2/arm-zephyr-eabi/bin/arm-zephyr-eabi-gcc -DBUILD_VERSION=zephyr-v2.2.0-2637-g6ba69f19d4a4 -DKERNEL -DNRF9160_XXAA -D_FORTIFY_SOURCE=2 -D__PROGRAM_START -D__ZEPHYR__=1 -I/home/stefan/zephyrproject/zephyr/subsys/net/ip -I/home/stefan/zephyrproject/zephyr/include -Izephyr/include/generated -I/home/stefan/zephyrproject/zephyr/soc/arm/nordic_nrf/nrf91 -I/home/stefan/zephyrproject/modules/hal/cmsis/CMSIS/Core/Include -I/home/stefan/zephyrproject/modules/hal/nordic/nrfx -I/home/stefan/zephyrproject/modules/hal/nordic/nrfx/drivers/include -I/home/stefan/zephyrproject/modules/hal/nordic/nrfx/mdk -I/home/stefan/zephyrproject/modules/hal/nordic/. -I../src -I../cifra/src -I../cifra/src/ext -isystem /home/stefan/zephyrproject/zephyr/lib/libc/minimal/include -isystem /home/stefan/zephyr-sdk-0.11.2/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/9.2.0/include -isystem /home/stefan/zephyr-sdk-0.11.2/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/9.2.0/include-fixed -Os -imacros/home/stefan/workspaces/oscore_edhoc_on_zephyr_modules/samples/cifra_test/build/zephyr/include/generated/autoconf.h -ffreestanding -fno-common -g -mcpu=cortex-m33 -mthumb -mabi=aapcs -imacros/home/stefan/zephyrproject/zephyr/include/toolchain/zephyr_stdint.h -Wall -Wformat -Wformat-security -Wno-format-zero-length -Wno-main -Wno-address-of-packed-member -Wno-pointer-sign -Wpointer-arith -Wno-unused-but-set-variable -Werror=implicit-int -fno-asynchronous-unwind-tables -fno-pie -fno-pic -fno-strict-overflow -std=gnu99 -fno-reorder-functions -fno-defer-pop -fmacro-prefix-map=/home/stefan/workspaces/oscore_edhoc_on_zephyr_modules/samples/cifra_test=CMAKE_SOURCE_DIR -fmacro-prefix-map=/home/stefan/zephyrproject/zephyr=ZEPHYR_BASE -fmacro-prefix-map=/home/stefan/zephyrproject=WEST_TOPDIR -ffunction-sections -fdata-sections -std=c99 -nostdinc -MD -MT CMakeFiles/app.dir/cifra/src/blockwise.c.obj -MF CMakeFiles/app.dir/cifra/src/blockwise.c.obj.d -o CMakeFiles/app.dir/cifra/src/blockwise.c.obj -c ../cifra/src/blockwise.c

Best regards
Stefan
I haven’t tried this, but you should be able to do something like what is done in:

set_property(GLOBAL PROPERTY CSTD gnu99)

At the top of your CMakeLists.txt

For example I did:

diff --git a/samples/hello_world/CMakeLists.txt b/samples/hello_world/CMakeLists.txt
index 29878daa90..bd26389e09 100644
--- a/samples/hello_world/CMakeLists.txt
+++ b/samples/hello_world/CMakeLists.txt
@@ -2,7 +2,9 @@

cmake_minimum_required(VERSION 3.13.1)

+set_property(GLOBAL PROPERTY CSTD gnu99)


- k

Join {users@lists.zephyrproject.org to automatically receive all group messages.