(My Arduino version is 1.8.2.)

For example,if I want to #include <vector> or <string>, <iostream>, <memory> etc, the compiler always complains that such libs are not found.

So what's the newest/most efficient way to use C++ libs in Arduino 1.8.2?


1 Answer 1


Most Arduino Core don't include the Standard C++ Library, that's why headers like <vector> and <string> are missing. This decision makes a lot of sense because the STL relies heavily on heap allocation, which would ruin the little RAM of the microcontroller.

If you're looking for an alternative to the STL, you might check out the ETL, the Embedded Template Library.. However, the code will not be the same because all the containers of the ETL have a fixed capacity. Here is a string for example:

etl::string<32> s = "hello world";

In practice, I never saw a project using the ETL. Most projects use the standard Arduino classes (String, Stream, Print...) and learn to live with their flaws. Since there are no generic container classes in the Arduino core, the common usage is to use plain old C arrays.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.