I’m trying to compile a C++17 project using std::optional for the Arduino Teensy. It works on my Linux machine, and on my Windows 10 VM, but I can’t get it compiling on my friend’s Windows 10 PC.
Can anyone suggest a solution to this?
The platformio.ini file;
[env]
build_unflags =
-std=gnu++11 -std=c++11
-std=gnu++14 -stc=c++14
build_flags =
-std=gnu++17
[env:teensy40]
platform = teensy
board = teensy40
framework = arduino
The main.cpp file;
#include <Arduino.h>
#include <optional>
auto GetOptional() -> std::optional<int>
{
return 42;
}
void setup()
{
auto value = GetOptional();
}
void loop()
{
}
The build error;
PS C:\Users\User\Documents\PlatformIO\Projects\cpp17test> C:\Users\User\.platformio\penv\Scripts\platformio.exe run -v -j1
Processing teensy40 (platform: teensy; board: teensy40; framework: arduino; build_unflags: -std=gnu++11 -std=c++11, -std=gnu++14 -std=c++14; build_flags: -std=gnu++17)
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------CONFIGURATION: https://docs.platformio.org/page/boards/teensy/teensy40.html
PLATFORM: Teensy (4.17.0) > Teensy 4.0
HARDWARE: IMXRT1062 600MHz, 512KB RAM, 1.94MB Flash
DEBUG: Current (jlink) External (jlink)
PACKAGES:
- framework-arduinoteensy @ 1.157.220801 (1.57)
- tool-teensy @ 1.157.0 (1.57)
- toolchain-gccarmnoneeabi @ 1.50401.190816 (5.4.1)
LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 92 compatible libraries
Scanning dependencies...
No dependencies
Building in release mode
arm-none-eabi-g++ -o .pio\build\teensy40\src\main.cpp.o -c -std=gnu++17 -fno-exceptions -felide-constructors -fno-rtti -Wno-error=narrowing -fpermissive -fno-threadsafe-statics -Wall
-ffunction-sections -fdata-sections -mthumb -mcpu=cortex-m7 -nostdlib -fsingle-precision-constant -mfloat-abi=hard -mfpu=fpv5-d16 -O2 -DPLATFORMIO=60113 -D__IMXRT1062__ -DARDUINO_TEENSY40 -DUSB_SERIAL -DARDUINO=10805 -DTEENSYDUINO=157 -DCORE_TEENSY -DF_CPU=600000000 -DLAYOUT_US_ENGLISH -Iinclude -Isrc -IC:\Users\User\.platformio\packages\framework-arduinoteensy\cores\teensy4 src\main.cpp
src\main.cpp:2:20: fatal error: optional: No such file or directory
compilation terminated.
*** [.pio\build\teensy40\src\main.cpp.o] Error 1
============================================================================= [FAILED] Took 2.13 seconds =============================================================================