How to properly convert c ++ project?
I successfully use some c++ code inside a .c file like
std::vector v = {1.2,2.3,4.5,5.6,6.7};
std::stack hp;
hp.push(“1221”);
hp.push(“test”);
hp.push(“stack”)
hp.push(” item”);
const char *data;
while( hp.size() > 0)
{
data = hp.top().c_str();
hp.pop();
USARTSendString(data);
}
USARTSendString(“\n”);
Just by changing ‘gcc’ to ‘g++’ in the project settings AND adding the flag ‘-fpermissive’
I know it is very far to be a good solution but I really need to use some C++ STL features, that’s the quick and dirty solution I found till now with the constraint that I want to keep my code in sync with CubeMX (which does not yet? generate C++ code if I’m right)
It compiles and runs on a F7...
It just makes the Eclipse indexer mad, I had hundreds of ‘unresolved symbols’ while the code compiles and links fine, I tried to find a workaround by googling a long time but nothing works, if you rename the *.c files in *.cpp files, than the indexer is happy but the code does not compile anymore for many other problems, so I just disabled the Eclipse indexer to avoid all the error messages polution but it is frustrating not to have this nice feature...
J.