Skip to content

Support C++ 20 modules#447

Draft
PyXiion wants to merge 6 commits intojbaldwin:mainfrom
PyXiion:modules
Draft

Support C++ 20 modules#447
PyXiion wants to merge 6 commits intojbaldwin:mainfrom
PyXiion:modules

Conversation

@PyXiion
Copy link
Contributor

@PyXiion PyXiion commented Feb 20, 2026

Modules reduce compilation times and improve encapsulation.

They're completely optional and don't break the code that uses headers.

Usage:

#include <coroutine> // still requires this header (or import std)
import libcoro;

@jbaldwin
Copy link
Owner

jbaldwin commented Feb 21, 2026

Honestly I hadn't considered adding modules anytime soon because everytime I look at them they don't seem to be ready to use?

ninja: build stopped: subcommand failed. doesn't seem great? I'm super out of my depth on adding this to the project TBH so I'm not sure I'll be much help without some good time investment. I do think this would be awesome to add though, I always thought modules could be absolutely revolutionary for C++ but I'm skeptical it'll ever work crossplatform well. Prove me wrong? lol

@PyXiion
Copy link
Contributor Author

PyXiion commented Feb 21, 2026

It's failing because the current CI uses an older tool chain that works with modules poorly. I'll set it up correctly for the modules a bit later.

Current support of modules in compilers is excellent in Clang 17+ and MSVC 2022+. Idk about GCC, Google says 14+ works with modules good.

In this PR I use export-using style as LLVM guidelines recommends, so it won't be hard to maintain.

If a user is on an old compiler, they just #include as usual. If they are on a modern stack, they can get the 20%-40% build time improvement from import.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants