r/cpp • • Sep 09 '26

C++26: Module improvements

https://www.sandordargo.com/blog/2026/09/09/cpp26-modules
113 Upvotes

25 comments sorted by

View all comments

Show parent comment

2

u/delta_p_delta_x Sep 09 '26

We should get rid of header units.

11

u/WeeklyAd9738 Sep 09 '26

Header-units are great for "importing" your own macros (however few they may be). Ironically, C++20 modules have made macros "safe" and more viable, as they no longer leak and pollute your client code and remain local to your translation unit. They can't be exported (by a module) and can only be imported using header-units. Header-units are also great for importing third-party dependencies which haven't migrated to C++ modules yet, or never will (C libraries).

1

u/germandiago Sep 15 '26

Just use include for your macros.

11

u/Daniela-E Living on C++ trunk, WG21 |🇩🇪 NB Sep 09 '26

Find your favourite telephone booth, dial in 2019 or earlier, and convince the header unit proponents 😊

Besides that, there are situations when header units are actually beneficial. Watch this year's conference talks of mine to learn how.

-6

u/pjmlp Sep 09 '26

Meanwhile Apple and Google keep being big users of clang header maps and are in no hurry to adopt C++ 20 modules, see Apple build for modules between Swift, Objective-C and C++ (explicitly builds module dependencies, missing modules related rows on C++ language support), and Google C++ Style Guide.