2020-06-01 02:46 AM
I have tried making a Project from scratch and selecting the C++ during the wizard, and also tried converting an existing project by going to properties and selecting convert to C++.
It just doesn't seem to be a C++ project.
I'm using a STM32L476RG dev board and select this board in the wizard process. I select the C++ option but none of the produced files have a CPP extension, including the main.c.
If I put the following in the main.c file:
#include <string> // I do not get an error on this line but...
string fred = "Fred"; // produces an error (or two)
../Core/Src/main.cpp:32:1: error: 'string' does not name a type; did you mean 'stdin'?
string fred = "Fred";
^~~~~~
Is this the correct way of generating a C++ project?
Does the main file need to be main.c or main.cpp?
Is there anything else I need to change?
Thanks,
Neil
Solved! Go to Solution.
2020-06-01 05:35 AM
Change string to std::string or use "using namespace std". Possibly string isn't put in the global namespace by default.
If you want C++, the file needs to be "*.cpp", as you did. STM32CubeIDE doesn't have good C++ support as of now.
2020-06-01 05:35 AM
Change string to std::string or use "using namespace std". Possibly string isn't put in the global namespace by default.
If you want C++, the file needs to be "*.cpp", as you did. STM32CubeIDE doesn't have good C++ support as of now.
2020-06-01 03:38 PM
Great thanks.