PlatformIO Community

C++/STL on an AVR Platform?

Hey, it is possible to use C++ on an ATmega328p-pu(Commonly known as Arduino Uno).
Best regards.

The Arudino framework is written in C++ and is supposed to be used with C++. (The .ino files are basically C++.) So clearly: Yes.

Is using the Arduino framework a good option for you?

I’m writing a Hardware Abstraction Layer from scratch, so I was wondering whether I could use some STL containers for that purpose.

Arduino is not really an option.

It seems that AVR supports C++ syntax and stuff, but seemingly not the STL, so I removed any STL includes, yeah raw pointers all the way :smiley:

So if you already have an environment that supports C++, you can use one of many libraries designed for restricted devices like the ATmega328P that implement a subset of STL or STL-like features.

Have a look at:

Even though two of them are designed for Arduino, they can likely be used in other environments with minor modifications.

1 Like

Thanks for the references.
I think I will stay with raw pointers and arrays, I guess. Might be neat with containers, but might be less efficient.