Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

g++ "generator: No such file or directory" - which version of GCC supports the <generator> header?

I've built GCC 13.2.0 that I believe has quite good support for c++23.

I'm trying to compile some code that would use the c++23 std::generator.

For example: https://en.cppreference.com/w/cpp/coroutine/generator

c++23 should have the generator header: https://en.cppreference.com/w/cpp/coroutine/generator

#include <generator>

However when I compile this with g++ I get the following error:

$ ~/opt/gcc/13.2.0/bin/g++ -Wall -std=c++23 generator.cpp -o generator
generator.cpp:3:10: fatal error: generator: No such file or directory
    1 | #include <generator>
      |          ^~~~~~~~~~~
compilation terminated.

My guess is that 13.2.0 does not yet have support for this feature, but I'm struggling to confirm that guess. My question is, which version of GCC supports this feature?

I looked on this page: https://gcc.gnu.org/projects/cxx-status.html but nothing stood out that would tell me the answer.

Also I looked on this page: https://gcc.gnu.org/onlinedocs/libstdc++/manual/status.html#status.iso.2023

like image 360
InTheWonderlandZoo Avatar asked Oct 23 '25 20:10

InTheWonderlandZoo


1 Answers

Thanks to HolyBlackCat, I found the answer is GCC 14.

At the time of writing this, 14 is not yet ready for release, but with a bit of poking around on gcc web site I found this page that seems to confirm it: https://gcc.gnu.org/gcc-14/changes.html

Improved experimental support for C++23, including:

...

The std::generator view for getting results from coroutines.

...

like image 191
InTheWonderlandZoo Avatar answered Oct 25 '25 10:10

InTheWonderlandZoo



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!