Does not build for strict C99 #339
Labels
No labels
bazel
bluetooth
board settings
boot_stage2
bug
build
c++
can't reproduce
clang
clib-interface
cmsis
code cleanliness
code size
compiler version issues
cyw43_driver
debug
discussion
documentation
duplicate
dynamic_clock
elf2uf2
enhancement
errata
filesystem
flash layout
floating point
FreeRTOS
hardware_adc
hardware_claim
hardware_clocks
hardware_dma
hardware_exception
hardware_flash
hardware_gpio
hardware_i2c
hardware_irq
hardware_pio
hardware_pwm
hardware_rcp
hardware_rtc
hardware_spi
hardware_sync
hardware_uart
hardware_vreg
hardware_watchdog
hardware_xosc
help wanted
host
IAR
installation
invalid
linker scripts
lto
lwip
mbedtls
missing API
needs reporter detail
networking
newlib
newlib-multicore
non-c
non-cmake
non-gcc
openocd
orphan PR
OS integration
pico_async_context
pico_base
pico_binary_info
pico_flash
picolibc
pico_lwip
pico_malloc
pico_multicore
pico_printf
pico_runtime
pico_stdio
pico_stdio_usb
pico_sync
pico_time
pico_util
pioasm
port
question
review
review2
rtos interop
runtime init
static library
svd
test
tinyusb
vscode
wifi integration
wontfix
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
gh-raspberrypi/pico-sdk#339
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
If compiler option -std=c99 is added the build fails because of some inline assembly instructions. While this is not a major problem, some projects require it.
Helpful if you give build output; also how you chose to add -std=c99
In my project I added the -std=c99 compiler flag in CMakeCache.txt, after running cmake, like this...
//Flags used by the C compiler during all build types.
CMAKE_C_FLAGS:STRING=-mcpu=cortex-m0plus -mthumb -std=c99
This line...
#include "pico/stdlib.h"
eventually includes platform.h, and it's this code that causes the error...
inline static int32_t __mul_instruction(int32_t a, int32_t b) {
asm ("mul %0, %1" : "+l" (a) : "l" (b) : );
return a;
The errors are first it thinks asm is a function and complains about an implicit declaration, then it barfs on the : in the middle as it's not C.
I have tried reproducing it using the standard examples, for example blink.c. I made the same change to pico-examples/build/CMakeCache.txt, but the blink project built without error so somehow the -std=c99 compiler flags I made is not getting transmitted through the examples build process.
My cmake file is unremarkable...
If it helps, the project I tried it on is here...
https://github.com/miniwinwm/miniwinwm/tree/master/RaspberryPi/Pico/MiniWinSimple
Does it work with
__asminstead ofasm?It gets through the asm problem, but then fails on static_assert in address_mapped.h. I think typeof in sem.c is going to be a problem as well. It looks like that one needs to be __typeof.
Note the best way to specify C99 is to do
which will do
--std=gnu99which gets use the asm/typeof stuff. You can add the followfor now. you can edit a header, or inject it via the
PICO_CONFIG_HEADER_FILESvariable:and it will be included in all files.
note that we don't claim to work with C99, however if the changes needed for support arer non invasive we will fix them individually
Thanks for your input. I shall work through the problems to see if I can make progress and if it's only trivial changes needed to get it to work I'll add them here.
C99 has no static assert, but one might use typedef trick to create one if there's no compiler-specific way
I am running into this problem now with trying to compile.
if i comment it out all good.
any thoughts to adding a check to all the static_asserts:
or piggy backing off of @Wirtos adding something like this to pico/assert.h:
Whoops, that one had a little mistake with concat being unused. Indeed this solution should work in most of the use-cases except static asserts declared inside structs or unions, also could add compiler-specific flags to silence unused warnings about declared typedefs