How to add compiler flags to PlatformIO project

In order to add compiler flags to your PlatformIO project, add the following line to your build config(s) in platformio.ini:

example.cpp
build_flags = -std=gnu++17

You can also use multiple lines:

example.cpp
build_flags =
    -std=gnu++17
    -ffast-math

Full platformio.ini example:

example.ini
[env:d1_mini]
platform = espressif8266
board = d1_mini
framework = arduino
monitor_speed = 115200
build_flags = -std=gnu++17

 


Check out similar posts by category: PlatformIO