2022-05-12 08:48 AM
Hey everyone,
I'm trying to make a project in C++. I tried the trick to rename main.c to main.cpp with the right-click > rename function. It works, but then if I change the IOC with the config tool, it will create a new main.c with the proper settings (and ignore main.cpp).
What would be the proper way to use C++? Is there a setting to have main.cpp updated in case of a config change ?
Solved! Go to Solution.
2022-05-12 12:36 PM
Many other thread on such topic. One is There is a plan to allow STM32cubeMX for generating main.cpp instead of .c only ?
2022-05-12 09:33 AM
> What would be the proper way to use C++?
The proper way to use C++ with CubeIDE is just three simple steps:
If you want to use a different IDE, please say so.
2022-05-12 12:36 PM
Many other thread on such topic. One is There is a plan to allow STM32cubeMX for generating main.cpp instead of .c only ?
2022-05-13 02:41 AM
Thanks. Actually I now know my problem was with header files for C++ where I didn't properly added
#ifdef __cplusplus
before C++ code (e.g. extern "C", including C++ libraries, ...) . So the compiler not knowing it was supposed to be C++ showed an error.
I think I now managed to do the "bridge" between C and C++, and that is what most users do: leave main in C and from there call my C++ call that is in other files.
2022-05-13 02:41 AM
Thanks!