Hacker Timesnew | past | comments | ask | show | jobs | submitlogin

> I'm curious if anybody is working to make C++ faster to compile.

Yes - C++20 added support for modules to the Core Language (both "header units" and "named modules"; header units are an intermediate step between classic includes and named modules), and support for header units to the Standard Library. Compiler/library support is a work in progress (MSVC's STL, which I work on, is the furthest along - see https://github.com/microsoft/STL/issues/1694 for status), but header units are showing significant improvements in compiler throughput (build speed). This looks like `import <vector>;` in your source code (with significant build system changes to build vector as a header unit, producing vector.ifc and vector.obj).

There's a proposal under review for C++23 to add named modules for the Standard Library, see https://wg21.link/p2465r2 . If this is accepted, `import std;` (or `import std.compat;`) will be the one-line way to use the entire C++ Standard Library with (what we hope will be) even better compiler throughput.

The primary limitation of header units and especially named modules is macros: neither can be influenced by macros defined in the source file, and named modules can't emit macros at all. Thus, one will still need to `#include <cassert>` in addition to `import std;` if you want the `assert()` macro.



Still looking forward to a solution for _ITERATOR_DEBUG_LEVEL in release builds with modules, VS DevCommunity ticket does exist.

Currently it appears anyone that cares about bounds checking and iterator validation in release builds, has to keep using global module fragments.


I have the opposite problem. I can't use modules because I need _ITERATOR_DEBUG_LEVEL=0 in debug builds.

The standard library modules really need to be built as part of your projects build so that you can compile them however you want.


Either that, or be like MFC/ATL and provide a couple of pre-compiled versions for common workflows.


Wow, thanks, can't wait for this.

How hard will it for library writers to supply their libraries as modules?

Will the only requirement be to remove macros?




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: