Let’s install and use the StandardCPlusPlus library in your Arduino environment. So you can imagine that some trade offs where made during the development of the library. Important note: Using STL on your computer and on Arduino (which is an embedded system) is clearly not the same thing, so don’t expect everything to work the same! The flash memory and SRAM on Arduino are about a few KiloBytes, whereas on your computers we’re talking in Gigabytes. So, even if you can’t natively use the STL, you can get some of its features from an external library. Basically it enables you to use the (“fake”) STL in Arduino, just by downloading and installing the library in your Arduino environment. The library we’ll use here is called StandardCPlusPlus. uClibc++ is a Cpp library created to be able to use the standard Cpp library in embedded systems.Īnd a few developers have also worked on porting this library to Arduino. Well, it started with the development of uClibc++.
So, how is it possible, if we previously said it was not? For example you can create classes in Arduino, however, you won’t be able to use exceptions, and the new/delete expressions. The Arduino language is a subset of C/C++, with some object oriented programming functionalities. If you check this post on What is the Arduino language, you’ll see that we clearly mention there is no way to use things like std::vector, std::string, or other features from the STL library. How is it possible, since STL is not a part of Arduino?
Std lib vector code how to#
You are learning how to use Arduino to build your own projects?Ĭheck out Arduino For Beginners and learn step by step. The library we’re going to use in this tutorial is quite old and doesn’t work on recent versions of Arduino IDE. So, you are using Arduino and you wonder if you can use the Cpp STL library in your code.Įven if some feature will still be lacking, or some others will be limited, you will be able to use things like std::vector and std::string in your Arduino programs.