Skip to main content
shabaz
Associate
November 15, 2020
Solved

C++ with STM32CubeMX and CubeIDE

  • November 15, 2020
  • 2 replies
  • 985 views

Hi,

I'd like to use C++, and I had a question.

Currently my procedure is:

(a) Configure the peripherals using CubeMX (since I wish to use MX HAL) and generate code .

(b) In CubeIDE I rename the main.c file to main.cpp, and then from the project window I right-click the project name and select Convert to C++

Although that procedure initially works, the problem is that if I subsequently wish to make additional peripheral configuration changes, things get messy, because if I use CubeMX and click on Generate Code, it won't modify the existing main.cpp and will instead create a new main.c file, because it thinks I'm coding in C. Now I have a merge problem to get the auto-generated content in main.c into main.cpp and then have to re-click on Convert to C++. What's the correct procedure I should be using?

This topic has been closed for replies.

2 replies

shabaz
shabazAuthor
Associate
November 15, 2020

Hello,

Thanks for the fast response!