How to include the standard c++ library in platformio in vscode?

I want to include “string” header file in my project, but i am not able to include the c++ std library. i also added “build_flags = -lstdc++” in the platformio.ini file.

What board are you compiling for? The AVR toolchain doesn't have support for the C++ standard library.

If you're compiling using a C++ compiler, there's usually no need to explicitly link to libstdc++, simly #including should be enough.

Please post the exact error messages you're getting, and all relevant code or configuration files.

Pieter

Just my curiosity but why do you post a question about platformio on this forum? As far as I understand it, it's an alternative IDE to the Arduino IDE.

Platformio seems to have its own forum where you probably have a better chance.

PieterP:
What board are you compiling for? The AVR toolchain doesn't have support for the C++ standard library.

If you're compiling using a C++ compiler, there's usually no need to explicitly link to libstdc++, simly #including should be enough.

Please post the exact error messages you're getting, and all relevant code or configuration files.

Pieter

I am compiling for arduino uno board.
exact error message: "'string' in namespace 'std' does not name a type",
even though i have included .
i guess i will use const char * for embedded boards.

sterretje:
Just my curiosity but why do you post a question about platformio on this forum? As far as I understand it, it's an alternative IDE to the Arduino IDE.

Platformio seems to have its own forum where you probably have a better chance.

i didn't know this forum is only for the official IDE, i thought the entirety of arduino ecosystem is covered. also i saw a few questions about platformio here.

You can always ask the question here :wink: However you might not get a solution for a problem with a 3rd party IDE as a lot of members are not using them.

The AVR toolchain doesn't have support for the C++ standard library.

That's about all there is to say. The normal C++ STL is pretty hopeless on a system with 2k of memory.
There have been some edited versions made for AVR, but you have to seek out and install them separately.
Try this one: GitHub - maniacbug/StandardCplusplus: Standard C++ for Arduino (port of uClibc++)