back

by AlexeyBrin·1y ago·view on hn ↗
How many modern compilers will let you write import std; in a C++ file and build the executable without shenanigans ? GCC 15 still does not let you compile a C++23 code with:

    g++ -std=c++23 -fmodules foo.cpp
Without manually generating the std module first. Until all compilers will directly accept the import keyword it won't be adopted on a large scale by regular programmers.
1 comments
Visual C++ and clang.

Many projects do just fine sticking to a single compiler.

Not for everyone, but they exist nonetheless, including on FOSS world.

AFAIK, Clang (like GCC) needs an extra step to compile the standard modules files. It does not work, as one would reasonably expect, with something like:

    clang++ -std=c++23 fname.cpp
(I know you can use Cmake to solve it - but I want a simple solution something that can be shown to a junior programmer.)