Skip to main content
etheory
Senior
February 23, 2020
Question

Setup STM32 Project wizard incorrectly generates C++ target

  • February 23, 2020
  • 1 reply
  • 1120 views

When I select the following options from the Project Explorer using "New->STM32 Project":0690X00000DC8sqQAD.jpg

One would expect that the project would be set up as a C++ project, especially considering that the option is presented to the user.

However this is not the case.

Choosing C or C++ produces exactly the same main.c and other files.

This option seems to serve no purpose.

Is there anything else I need to do to have the entire project work as a C++ project, or do I have to continue using the usual 'extern "C"' work-arounds that I'm currently using?

This topic has been closed for replies.

1 reply

KnarfB
Super User
February 23, 2020

A C++ project has C++ compiler build settings but does not generate C++ files. You can add your own C++ files and call your C++ functions from a user code section in main() in main.c using C++ extern C. This separates all generated code from your C++ code and works well for me, e.g. for using ROS (rosserial) code.