Guide for using C++20 or C++23??

Hello,

After playing around with the examples, I was thinking about using Daisy seed as a learning platform for C++ generally. I downloaded LibDaisy and I am trying to just build a blink led with a different C++ version.

Until now I tried make/cmake in LibDaisy folder by modifying the Cmakelists.txt for 20 or 23 version. Also made the same change in cmake/DaisyProject.cmake. And then building inside the GPIO output folder. Strangely this seems to throw off the cmake file generation and creates a lot of files that are maybe not predicted.

Untracked files:
  (use "git add <file>..." to include in what will be committed)
        CMakeCache.txt
        CMakeFiles/
        Drivers/CMakeFiles/
        Drivers/Makefile
        Drivers/cmake_install.cmake
        Drivers/libCMSIS_DEVICE_H7.a
        Drivers/libSTM32H7XX_HAL_DRIVER.a
        Middlewares/ST/CMakeFiles/
        Middlewares/ST/Makefile
        Middlewares/ST/cmake_install.cmake
        Middlewares/ST/libSTM32_USB_DEVICE_LIBRARY.a
        Middlewares/ST/libSTM32_USB_HOST_LIBRARY.a
        Middlewares/Third_Party/FatFs/CMakeFiles/
        Middlewares/Third_Party/FatFs/Makefile
        Middlewares/Third_Party/FatFs/cmake_install.cmake
        Middlewares/Third_Party/FatFs/libFatFs.a
        cmake_install.cmake
        examples/CMakeFiles/
        examples/GPIO_Output/CMakeFiles/
        examples/GPIO_Output/GPIO_Output.elf
        examples/GPIO_Output/GPIO_Output.hex
        examples/GPIO_Output/cmake_install.cmake
        examples/Makefile
        examples/cmake_install.cmake
        libdaisy.a

Anyway I believe that I succeded in running c++23 and c++20 as I had to make a small fix that seems as a common breaking point. (Not supporting volatile x|= foo;)

However folder structure from cmake is quite broken. Obviously cmake is not my strong point. So my question is if you have some guide or tips on migrating the project to c++20 and beyond.

Thank you

We unfortunately don’t have a guide on using C++20 or C++23 at the moment as far as I know.

There were discussions about CMake and C++20 & C++23 on the Daisy Discord’s #cpp channel which you may find helpful for the time being (I totally understand that it’s not ideal to direct people to Discord as a response so I’m sorry for my lack of knowledge).

C++20 and C++23 seem to have useful features so we could look into creating a guide (the engineers in the team could be using either C++20 or C++23 already so I can ask).

Hello, eventually I figured out my way. I must say that I am using only libdaisy submodule and I must say that probably cmake is not working in isolation with the rest of the projects

The job is done rather through the makefile on libdaisy folder and the makefile in example directories. Those seem to be not generated and actually cmake generation overwrites them with unpredictable results. Luckily even though I do not understand cmake I am fairly proficient with makefile.

The main problem is that you claim we have to use arm-none-eabi toolchain 10.3 at most as code breaks. This one supports at most c++20 experimentally. Since I run ubuntu 22.04 on this moachine which officially comes with 10.3 toolchain I am thinking of keeping it that way for now. This is done with just writing this on the corresponding line of libDaisy makefile.

CPP_STANDARD ?= -std=gnu++2a

Also after that the same error appears that I mentioned earlier that is simply solved with adding one more flag on the c++ flags

CPPFLAGS += \
-fno-exceptions \
-fasm \
-finline \
-finline-functions-called-once \
-fshort-enums \
-fno-move-loop-invariants \
-fno-unwind-tables \
-fno-rtti \
-Wno-register \
-Wno-volatile

I managed to build, program and debug(with gdb console presently I have to figure out the vscode gui). GPIO-Output in libdaisy folder had wrong pin for blink led though.

So one question is what exactly breaks with arm-none-eabi > 10.3. Can anyone answer if libdaisy submodule is unaffected by using >10.3??

Anyway, I am a professional embedded systems engineer (I mostly wrote C and a lil bit of arduino C++) and I want to use your hardware and your project as a learning C++ platform. I also play guitar, bass and synth. I am planning on using your (libdaisy) project as a base and maybe rewrite a lot of it ( I am not a fan of the many layers of abstraction).

Cheers

Since v7.0.0 of libDaisy you should be able to use newer versions of the ARM toolchain (this updated the STM32 HAL to a newer version that would build with the newer compiler versions).

Our CI does a build test with these versions:
latest, ‘13.3.Rel1’, ‘12.3.Rel1’, ‘11.3.Rel1’, ‘10.3-2021.10’, ‘9-2020-q2’

I’ve used pretty much all of them at this point, and I don’t think I’ve run into any specific issues.

Also, I am still mostly using the Make builld, but I will often use C++17 (or less often C++20) in my actual application source, but leave libDaisy compiliation where it’s at (C++14).

I think this should still be possible in CMake if you do run into issues down the road that you don’t want deal with, but would still like to take advantage of new language features in your app code.

I have made my own version of a stripped down project that I use with c++23 since then.