What compiler is PIO using and how do I change it?

First, how do I determine which compiler version is being used? Second, how do I change it to the latest standard?

Here’s the contents of my platformio.ini file:

extra_scripts = pre:use_json2cpp.py
monitor_speed = 115200
build_flags = -std=c++2a -std=gnu++2a
build_unflags = -std=gnu++11

platform = nxplpc
board = lpc1768
framework = mbed

I’m getting the following error messages despite these settings:

‘if constexpr’ only available with ‘-std=c++17’ or ‘-std=gnu++17’

This is what I have:

; https://docs.platformio.org/en/latest/projectconf/sections/env/options/build/build_flags.html
build_flags =
    ; The default for Apple Clang is… `c++98` o.O
    ; https://discord.com/channels/583251190591258624/1075788561334415360
    ; The default for ESP8266 toolchain is `gnu++17`:
    ; https://github.com/esp8266/Arduino/blob/master/platform.txt#L43

    ; Enables many recommended warnings at once
    ; https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html

The NXP LPC platform with mbedos as the framework will use GCC 9.2.1 by default

this compiler should be capable of C++17 and C++2a per this.

  1. Make sure that in the standard settings (without build_unflags and build_flags), it was actually using gnu++11. Otherwise your build_unflags = -std=gnu++11 is incorrect. Check project tasks → Advanced → Verbose Build and look for the compile command on a .cpp flie.
  2. You can chose a different compiler, up to GCC 12.3.1, per available versions and documentation, as a change of the toolchain-gccarmnoneeabi pacakge.