hachyderm.io is one of the many independent Mastodon servers you can use to participate in the fediverse.
Hachyderm is a safe space, LGBTQIA+ and BLM, primarily comprised of tech industry professionals world wide. Note that many non-user account types have restrictions - please see our About page.

Administered by:

Server stats:

9.5K
active users

Dani (:cxx: modules addict)

Cool, cool!

After a long fight with CMake, Clang, and gcc, I can report progress on the C++ modules front. 🎉

The argparse library is a good subject because it is not too large and has an extensive test suite. With my changes, it can be used as header, module, or both! It can use a modularized standard library, too, if present.

- Clang passes the tests but fails with merging a few definitions
- gcc can merge, but falls apart when using it as module
- MSVC passes all tests

You usually build the argparse module in 'attached' mode, i.e. all entities are attached to the named module.

The tests use two module builds: attached and detached. The latter detaches the entities from the module and glues them to the so-called global module. This allows for mixing the module with the traditional like I do in the module mixed mode test. It is supposed to work because compilers are required to do definition merging if the same entities come from more than one TU.

This is where both Clang 18 and gcc 14 have a hard time.

Clang is mostly there but fails in three test cases where it can't merge the definitions. Hence no mixed mode tests for Clang.

Gcc can merge, but is utterly confused when asked to use its own built module 🤯🤪

MSVC does exactly what it is supposed to do.

All three compilers fail to standard library headers *after* importing their modularized standard library, but that's expected - unfortunately. More love needed to merge...

What does this mean?

As we all know, modules have *two* interfaces, not just *one* like with .

All three compilers can build interface one (the *inward* looking) that's built during compilation of the primary module interface unit.

Interface two (the *outward* looking one) is the interesting one: can it be used by consumers of a module?

- Clang 18.1: ✅
- Gcc 14.1: ❌
- MSVC 17.10: ✅

Both Clang and MSVC also have a usable modularized standard library.