cancel
Showing results for 
Search instead for 
Did you mean: 

STM32CubeMX improvement suggestion

schelven
Associate II
Posted on December 03, 2015 at 10:33

Hi CubeMX team,

Thanks for making this wonderful user friendly tool !!

I would like to see an option to have main.c generated as main.cpp file.

Thanks, Rob

#cpp-c++-main.c-main.cpp-cubemx
2 REPLIES 2
stm32cube-t
Senior III
Posted on December 10, 2015 at 15:00

Dear Rob,

As you probably noticed already HAL drivers are ready to be used in a C++ project. You can generate a project with CubeMX. Opening  the generated project in your preferred toolchain (still using STM32CubeMX generated main.c file), you can add user files with .cpp/.hpp extensions.

Changing project options ( --cpp in uvision for example), you can choose to compile it as a C++ project .

By requesting a main.cpp file, do you expect to have object oriented encoding for this file (C++ classes, namespaces, etc...)  which would defer from current main.c architecture?

Thanks in advance for your feedback

schelven
Associate II
Posted on December 14, 2015 at 23:44

Dear STM32Cube-T,

Thanks for your reply. I did not realize that i could compile main.c as .CPP file. This solved my ''problem'' I was wondering how to get a function called from main.c that resides in a .CPP file. I solved it to look at the generated linker map file what the decorated name of the function became. But your suggestion is far better !!

I don't intend to place classes etc in main but all in external files. 

 

Thanks, Rob