Cannot open source file for C++ library includes

Hello, whenever I try to include a standard C++ library in an .hpp or .cpp file, I get the error “cannot open source file”

An example of how I’m importing them is simply:

#include <string>
#include <vector>

Includes such as

#include "Arduino.h"

work just fine. I think my problem is that only the C compiler is being invoked and not the C++ compiler. I’m on Windows so I followed C++ programming with Visual Studio Code and Get Started with C++ and Mingw-w64 in Visual Studio Code including the part where I add the /bin directory to PATH, making sure there are no spaces in it.

Here are the intellisense/compiler settings from c_cpp_properties.json:

"intelliSenseMode": "clang-x64",
"cStandard": "c11",
"cppStandard": "c++11",
"compilerPath": "\"C:/Users/joshb/.platformio/packages/toolchain-atmelavr/bin/avr-gcc.exe\" -mmcu=atmega328p"

Here is my platformio.ini file:

[env:uno]
platform = atmelavr
board = uno
framework = arduino
monitor_speed = 115200

Any help would be much appreciated. :slight_smile:

Maybe someone could tell me, how normal is including C++ libraries in your Arduino code and is it difficult to get C++ compiling with Platformio? It seems to me like most people don’t have to configure anything and these base libraries are recognized.

Found out the C++ libraries I’m trying to include are part of the STL which is part of Arduino by default

You might want to read more of the answers on that linked thread… as they quite clearly say the OP is incorrect in thinking STL is already part of the Arduino IDE by default. It’s the fact that it isn’t present that libraries like this exist…

… as well as the older one by maniacbug.