cancel
Showing results for 
Search instead for 
Did you mean: 

how to use a string (class) in ST32 Cpp code

MBany.1
Associate

hello everyone

I'm trying to use a string type (string class not char pointer or array) in my code

I have a lot of string messages in my program and a string class can help a lot

I see how arduino did it in their IDE, their string class is good, I think it should be possible to use it with ST32 MCUs,

I'm using Discovery (disco1) board with ST32CubeIDE.

1 REPLY 1
TDK
Guru

Convert your project to C++ (right click project -> Convert to C++), add a C++ source file, and use string within it:

#include <string>
 
std::string this_is_a_string = "Hello world!";

I verified this compiles but I did not test functionality.

You can also rename source files from *.c to *.cpp, but this can mess up global function references unless you do "extern "C"" to keep C linkage.

If you feel a post has answered your question, please click "Accept as Solution".