FreeRTOS + GCC + CMake

I tried to add FreeRTOS on my CMake Project but in compile time I get some error like this:

[build] ../system/FreeRTOS/portable/GCC/ARM_CM3/portmacro.h:135:51: error: unknown type name 'inline'
[build] **attribute**( ( always_inline ) ) static inline uint8_t ucPortCountLeadingZeros( uint32_t ulBitmap )

I think this error happen because in the FreeRTOS, CMakelists.txt at line 296 say to compiler use C90 standard.

set_property(TARGET freertos_kernel PROPERTY C_STANDARD 90)

I tried with C99 and C11 unfortunately got error to ASM line’s like this:

[build] /usr/bin/arm-none-eabi-gcc -DprojCOVERAGE_TEST=0 -I../system/FreeRTOS/include -I../system/FreeRTOS/portable/GCC/ARM_CM3 -isystem ../system -g -fdiagnostics-color=always -Wall -Wextra -Wpedantic -Werror -std=c11 -MD -MT system/FreeRTOS/CMakeFiles/freertos_kernel.dir/portable/MemMang/heap_4.c.obj -MF system/FreeRTOS/CMakeFiles/freertos_kernel.dir/portable/MemMang/heap_4.c.obj.d -o system/FreeRTOS/CMakeFiles/freertos_kernel.dir/portable/MemMang/heap_4.c.obj -c ../system/FreeRTOS/portable/MemMang/heap_4.c
[build] /tmp/cc7OqtJX.s: Assembler messages:
[build] /tmp/cc7OqtJX.s:219: Error: selected processor does not support requested special purpose register -- `msr basepri,r3'
[build] /tmp/cc7OqtJX.s:220: Error: selected processor does not support `isb ' in ARM mode
[build] /tmp/cc7OqtJX.s:221: Error: selected processor does not support `dsb ' in ARM mode

but when I change this line to use GNU99 standard, error is gone!


Development board: [STM32F103CBT6]
Instruction Set Architecture: [ARM Cortex-m3]
IDE and version: [vscode]
Toolchain and version: [GCC arm-none-eabi-8.3.1]


Host OS: [Linux]
Version: [Debian 11.6]

when I add target_compile_options to freertos_config and add -mcpu=cortex-m3
-mthumb flag kernel compile with c99 without error but with c90 has error

    target_compile_options(freertos_config INTERFACE

Does it compile with the -Wpedantic option removed?

[edit] I was able to try this myself and see that isn’t the cause, and concur setting the explicit C standard is. Either updating the cmake file or using __inline__ instead of inline within the port specific header could be options - I will discuss internally then update the github bug report accordingly.[/edit]

Thank you, I waiting for your feedback :smiley:

I think the immediate step is to remove this C90 requirement from CMake. I raised this PR for the same -Remove C90 requirement from CMakeLists by aggarg · Pull Request #649 · FreeRTOS/FreeRTOS-Kernel · GitHub.

Would you please confirm if this fixes your issue?

thank you, yes this pull request absolutely fixed my issues