Strings in C++ class file for Arduino not compiling
arduino, c++, string
Solution
Arduino sketches don't support any of the C++ standard library as they are compiled using avr-libc which doesn't support it. However, Arduino does provide the `String` class which should do what you need.
If you are writing a library you'll also need to `#include <Arduino.h>` (or `#include <Wiring.h>` if you are using a pre-1.0 version of the Arduino IDE).
Problem
I'm writing a stack class in C++ for an Arduino sketch. I believe it is fully compliant with the AVR (if that's what it's called; I can't remember exactly) compiler; I've used all `malloc` and `free` instead of `new` and `delete` and so on. So I have a .h file with my class. I've imported it into the sketch, but when I try to compile, I get these errors: ``` In file included from sketch_may15a.cpp:1: /CStack.h:58:18: error: string: No such file or directory In file included from sketch_may15a.cpp:1: CStack.h:61: error: variable or field 'Error' declared void CStack.h:61: error: 'string' was not declared in this scope ``` And here are the first few lines for my class: ``` #include <string> using namespace std; void Error(string message) { ``` So the Arduino compiler can't find `<string>`, and the next few problems seem to relate to it (not sure what `variable or field Error declared void` means, my error function is just for debugging purposes). I know Arduino sketches support strings without need for an import, but I'm not sure how that works out with C/C++/.h files. I've tried googling it, but there isn't much documentation.