C++17 is unrecognized build flag

this is my platformio.ini file:

[env:adafruit_itsybitsy_m4]
platform = atmelsam
board = adafruit_itsybitsy_m4
framework = arduino
lib_deps = 
    https://github.com/davidbitton/legilimens.git
    https://github.com/davidbitton/senoval.git
build_flags =
    -Wall -std=c++17

which results in

arm-none-eabi-g++: error: unrecognized command line option '-std=c++17'

I ran this from the command line:

$ arm-none-eabi-g++ -std=c++17
arm-none-eabi-g++: fatal error: no input files
compilation terminated.

and while I had nothing to compile, I had no unknown command error. Is PlatformIO using it’s own version of the compiler? What do I need to do to compile with c++17? Thanks!

Could you try Advanced Scripting and pass flag directly yo GCC/G++?

extra_script.py

Import("env")

env.Append(CCFLAGS=["-std=c++17"])
2 Likes

It seems the version of gcc used for esp8266 is 4.8.2. C++14 support began showing up in 4.9 and 5.0.

$ ~/.platformio/packages/toolchain-xtensa/bin/xtensa-lx106-elf-g++ --version
xtensa-lx106-elf-g++ (GCC) 4.8.2
Copyright (C) 2013 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Good to know. Thanks!