cancel
Showing results for 
Search instead for 
Did you mean: 

STM32 with Atollic (C++ project)

JOF
Associate II

My task is to change our current microcontroller solution to STM32, for this i choose to use Atollic True Studio. My goal is to keep the current software and only replace the hardware access (which is the only mcu specific part).

Since all the libraries are C++, i tried to convet the project from cube to c++ with the follwoing steps

  1. Select MCU in Cube, generate project
  2. Open Project in Atollic (9.0)
  3. File-> New-> Convert to C/C++ and execute the procedure
  4. Rename "main.c" to "main.cpp"
  5. Project->Properties->C/C++ General-> Paths and Symbols and copy all paths from C to C++
  6. "main.h" add line "define __cplusplus
  7. Generate

Now i'm getting alot of errors, most comming from the lines that contain the followin code:

#ifdef __cplusplus
 extern "C" {
#endif
 
....
 
#ifdef __cplusplus
}
#endif

And the error (~15 times) is called:

expected identifier or '(' before string constant

Another error i already get is

unknown type name 'uint32_t'

What could be the solution to this problem?

4 REPLIES 4
AvaTar
Lead

Seems the wrong approach to me.

> Select MCU in Cube, generate project

AFAIK, Cube does not support C++.

Second, the framework of your application is defined by the structure of said existing application. I would really wonder if that matches with the restrictions and quirks of Cube.

I would check if the project to port is properly layered, i.e. you can separate the more abstract application parts from the low-level hardware dependant code. If not (sh*t happens), you might be better of rewriting it.

Then I would generate a fresh C++ project in Atollic for the MCU, and add the high-level code directly.

Low level code needs more attention, consider different peripherals, interrupt mechanisms and priorities, timing inter-dependecies, and MCU concepts (like FIFOs vs. DMA).

uint32_t is a CMSIS standard type define.

Pavel A.
Evangelist III
AvaTar
Lead

> uint32_t is a standard c++ and c99 typedef.

The toolchain for my current projects is from the 1997...

JOF
Associate II

Mabye i forgot to say, that i don't have imported any custom content in the project, i just generated "emtpy" project via cube, and that does not compile. I really don't understand why the cube application should limit the code, since the "ifdef __cplusplus" is already present everywhere, i guess it should be meant to be possible to convert C++. I don't think the cube isnt to blame here, its more a problem of the IDE (Atollic True Studio).

If my approach is wrong, what would be the propper way to set up a C++ Project with the STM32?