I would also like to know this, I'm using a library that is C++ and you can change the main.c to main.cpp but if you have some functionality in main.cpp already it's a bit of a pain..
I guess the work around would be to change the cpp file to a c file then changing it back to a cpp file using F2(rename) after you have made the changes in .ioc
When creating your project, choose C++ as targeted language for your STM32 project.
Add 2 new files to your project. maincpp.h and maincpp.cpp. In maincpp.h you include main.h and declare two extern "C" functions: setup() and loop() which you implement in maincpp.cpp using C++. In main.c include maincpp.h and call setup() in a user code section right before the main loop and loop() in a user code section within the main loop. Now you have separated generated C code from your own C++ code.
Note that C++ may generate more code and some C++ libs use dynamic memory heavily which might cause issues.