How to properly convert c ++ project? Posted by HamedJafarzadeh on 2016-07-02 06:45 Any new solution for converting project to C++ ?
Posted by jea74 on 2016-07-02 14:04 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.
Posted by dautrevaux on 2016-07-03 12:59 Hi, The simplest solution is to right-click on your project >> Convert to C++ You just have to check that your install of System Workbench for STM32 is up to date (Help >> Check for Updates.... Of course you must still name your C++ source files with a .cpp extension instead of .c; Standard C source files are still compiled by teh C compiler, only C++ source files are compiled by the C++ compiler. Bernard (Ac6)