STM32 and Atollic: C++ possible?
Hello,
We are currently evaluating a replacement solution for our current microcontroller. STM32 is currently one of the favorite contestants.
The current software is written in C++ and uses alot of code that is pure C++, so no relation to the actual hardware used. In case of a replacement, we only would have to adjust the hardware commands like SPI Transmission command, if the new MCU would support C++. In case of only C support, we would have to re-write all of the C++ libraries followed by extensive testing. This would result in weeks of work and therefore cost.
When i took a look at Atollic, i noticed that is advertised as "Highly optimized C/C++". Sadly i noticed that CubeMx only creates C code, and the HAL-Libraries are all C. There are a lot of different tutorials on the internet that claim making Atollic Projects C++, but alot of them are get no response if its truly working.
So it tried the following steps:
1.) Generate Emtpy project with CubeMX
2.) Edit the .cproject file and add
<nature>org.eclipse.cdt.core.ccnature</nature>
3.) Edit the Projects->Properties->C/C++ General ->Paths and Symbols; copy all links from GNU C to GNU C++
4.) Rename Main.c to Main.cpp
5.) Restart, then build
I get alot of errors: just a few examples:
../Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_gpio.h:253:25: error: 'GPIO_TypeDef' was not declared in this scope
../Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_gpio.h:253:55: error: expected primary-expression before 'GPIO_Pin'
../Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_gpio.h:254:74: error: expression list treated as compound expression in initializer [-fpermissive]
So it does not seem to work at all.
I tried to make a new project via File->New->C++ project and selected the microcontroller of choice. Then i'm getting a compilable C++ project but without the structure and the HAL-Library. It seems just to be another library there and the main looks very different.
It would be very good if it would be possible to convert a CubeMX Project to C++. The cube functionality doesn't have to work after the first start, since in case of change one could just use a text-diff to manually insert changes made in the cube project.
Hopefully someone here can help me with this. It would be superb to get C++ Project with Atollic :)
