I would like to gain access to certain C++17 features for my projects which primarily use ESP32 and AT MEGA 2560 processors. I set my c++Standard to c++17 but that does not seem to help me. The discussion on this that I find in the forum is over 18 months old so I imagine a lot has changed since then. Below is a typical platformio.ini file for my projects which would be built to run on either of these two processors. Is there a setting in the platformio.ini that I need to add? Also, any adverse impact to libraries if I try to make this change?
Should be no problem with the current toolchain, just make sure to build_unflags = -std=gnu++11 (to get rid of the default) and add build_flags = -std=gnu++17.
The C++ STL support in avr-g++ was always terrible, even in the latest-greates AVR-GCC/G++ 12 compilers. However, as you can see in
if you choose a board definition that uses the alternative MegaCore (which suppoerts ATMega2560 too), it gives you GNU++17 already. So just ues board = ATmega2560 and the language features should work out of the box.
Thanks for that rapid reply. Unfortunately, I did not experience success with those changes. I made a smaller test case and I got a few namespace errors indicating to me that it was still not using c+17
namespace “std” has no member “variant”
namespace “std” has no member “visit”
just a bit of the code… for that first namespace error:
using AT = double;
using PT = unsigned long long;
using R = std::variant<AT, PT>;
and my platformio.ini (in case I did not understand you correctly…
Hi Max. As always, you are correct… I left out the Arduino.h include… BUT, I am still having issues with C/C++ intellisense highlighting namespace errors for std::variant and std::visit. I am running C/C++ Extension Pack v1.2.0 and have set C/Cpp > Default:Cpp Standard to c++17. Is there a setting I am missing to get the intellisense to not show these “errors”?