I recently took up programming some Arduino code and was rather disappointed to find that Arduino brewed up it's own string handling class "String" rather than something that is code compatible with the STL string class. Over the past couple decades or so I've developed a substantial library of C++ code libraries that use STL classes, and I'd really like to be able to use them in my Arduino projects without having to branch them and rework them specifically for Arduino. I don't necessarily need the full implementation of an STL string class--the Arduino String class has a most of what I need, but it is syntactically different. For example, string::size() in STL is equivalent to String::length() in Arduino.
I have a project where I'm writing code for Arduino and code for Windows that talks to each other. Since the two sets of code talk to each other, in several cases I want to use the exact same code on both ends. So far I've had to copy the Windows classes and rewrite them for the Arduino code. It's maddening when I have to make nearly identical edits to two nearly identical files.
Has anyone else here run into the same issue and figured out a good way of getting around this?
Thanks!
@OP the String class provided by the C/C++ compiler (and the language is C/C++) is a standard. In addition the STL are available i you wish (we are after all using C/C++). string (null terminated array of char) however is not a class but something that started in c and having proved it worth has continued in use.
You are strongly advised NEVER to use the String class (STL or otherwise). on the arduino's. Search this forum for the 100's of discussions the subject.
One question: I agree that is better use the "standard C string" instead of the String class, mostly because I came from "plain C" instead of C++. Now if is so wrong using String class, why the IDE came with a whole lot of sample code using String class?