C++20 ranges library: fatal error: ranges: No such file or directory

Hey there,

I just started a project for my LilyGo T-Display-S3. I had some old code for an ESP8266-based board lying around, and I’m trying to make that compile for this new board. In one of the files, I try to include the C++20 ranges library, however, and that yields this error: fatal error: ranges: No such file or directory.

What is up with that?

My platformio.ini file looks like this:

[env:lilygo-t-display-s3]
; platform = espressif32
platform = https://github.com/platformio/platform-espressif32.git
board = lilygo-t-display-s3
framework = arduino
build_unflags = -std=gnu++11
build_flags = -std=gnu++2a //https://community.platformio.org/t/which-c-standard-am-i-using/24597/4

I can’t quite tell which compiler is being used here. Does it not support the ranges library yet?
In that case, I wonder why I had no trouble with the ESP8266. I would expect the support for the ESP32 to be better.

Your build_flags / unflags are correct.

However, this does not change the fact that Espressif’s xtensa-esp32-toolchain is missing the necessary header files.

(Same as here: Possible to use C++20 for ESP32 with Arduino framework)

Thank you for the swift response!

So, if I understand you correctly, the toolchain simply does not support this yet.
Since you mention that it’s only missing some header files, is there some way to hack around this?
Or at least some place to read more about this, like a GitHub issue?

I think the question should be put to Espressif. (GitHub - espressif/esp-idf: Espressif IoT Development Framework. Official development framework for Espressif SoCs.).

Issue #12914 goes into the same direction.

Core statement from igrr:

This will be supported starting from GCC 14, see 104167 – Implement C++20 std::chrono::utc_clock, std::chrono::tzdb etc.. We will likely have a GCC 14.1-based toolchain a few months after the official upstream release. For now you can use one of the libraries which work as a drop-in replacement.

Alright, thank you for pointing me in the right direction. It’s been a while since I’ve done embedded development, and these things sure do involve a lot of different parties (PlatformIO, Arduino, Espressif), which can make it hard to know where a given problem stems from.

I’ll focus on Espressif and do some more digging.

I can understand you very well. I feel the same way :slight_smile:

1 Like

A little update:

After posting in the ESP32 Forum, I created this issue on GitHub.

(Continuing last post, because I’m only allowed to post two links per post)

Which lead me to GitHub - Jason2866/platform-espressif32: Tasmota Espressif 32: development platform for PlatformIO. At a first, quick glance, using this platform seems promising.

The answer from igrr is what I was hoping for.
Finally a change to IDF 5.x with an updated toolchain and much more functionality.
Let’s hope for a timely release of espressif32-arduino version 3.x and quick availability in PlatformIO!