Hello all, I am started playing with mbed-cmake (GitHub - USCRPL/mbed-cmake: Use the power of CMake to create your MBed applications) and I managed to successfully compile the hello_world example program for different targets (NUCLEO_F401RE, NUCLEO_G474RE and NUCLEO_F429ZI), but a compiler error appears using NUCLEO_F303K8.
I have updated the mbed-os to the latest one (6.16) just to check if this was the cause but it is not, I have also successfully compile the blinky program using mbed studio with this target so it seems it is related to something specific to mbed-cmake, here you are the process I followed and the reported error.
git clone --recursive https://github.com/USCRPL/mbed-cmake-example-project.git
git submodule foreach git pull origin master
python3 mbed-cmake/configure_for_target.py -a mbed_app.json -i .mbedignore NUCLEO_F303K8
create a build directory , enter into it
cmake --fresh "-G Ninja" C:\Mbed-Cmake\mbed_ws\mbed-cmake-example-project -DUPLOAD_METHOD=STM32CUBE
ninja -j2 hello_world
This is the reported error:
In file included from c:\progra~2\armgnu~1\1213fb~1.2mp\arm-none-eabi\include\newlib.h:10,
from C:/Mbed-Cmake/mbed_ws/mbed-cmake-example-project/mbed-cmake/mbed-os/platform/source/newlib_nano_malloc_workaround.c:60:
C:/Mbed-Cmake/mbed_ws/mbed-cmake-example-project/mbed-cmake/mbed-os/platform/source/newlib_nano_malloc_workaround.c:62:6: error: token "@" is not valid in preprocessor expressions
62 | #if (__NEWLIB__ == 4) && (__NEWLIB_MINOR__ == 1) && (__NEWLIB_PATCHLEVEL__ == 0)
| ^~~~~~~~~~
[63/249] Building C object mbed-cmake/mbed-os/CMakeFiles/mbed-os-static.dir/platform/source/minimal-printf/mbed_printf_implementation.c.obj
ninja: build stopped: subcommand failed.
but it is not a problem of Mbed, it is a bad bug in the newlib. You can modify the header file in your local gcc installation, or upgrade gcc to the recent version 12.2.Rel1, there it is fixed.