PlatformIO follows the compilation settings of the original frameworks, so e.g. for ESP32 + Arduino (core 1.0.6), C++11 is the standard used in there in the Arduino IDE, and so PlatformIO has that as a default. If the used compiler is capable of a higher C++ standard and if the code is compilable for that higher standard, build_unflags
and build_flags
can be used.
If we’re talking about the standard ESP32 + Arduino case here, note that PlatformIO is currently lagging behind regarding the used core version, and with it the used C++ standard (see issue).
As can be deducted from this comment, it’s possible to get a technical preview of the 2.0.1 core with C++2a (highest version in the 8.4.0 compiler) by using the platformio.ini
[env:esp32dev]
platform = https://github.com/platformio/platform-espressif32.git#feature/arduino-idf-master
board = esp32dev
framework = arduino
platform_packages =
framework-arduinoespressif32 @ https://github.com/espressif/arduino-esp32.git#2.0.1
build_unflags = -std=gnu++11
build_flags = -std=gnu++2a
NOTE: The information in this post is outdated and the platformio.ini
should not be used anymore. While the Arduino-ESP32 core still uses Gnu++11
https://github.com/espressif/arduino-esp32/blob/master/tools/platformio-build-esp32.py#L50-L55
the custom platform
and platform_packages
should not be used anymore. Instead just:
[env:esp32dev]
platform = espressif32
board = esp32dev
framework = arduino
build_unflags = -std=gnu++11
build_flags = -std=gnu++2a