Skip to content

Latest commit

 

History

History
53 lines (38 loc) · 2.85 KB

README.md

File metadata and controls

53 lines (38 loc) · 2.85 KB

C++20 Modules Examples

NOTE: this master branch contains examples of header units and uses import instead of #include for headers in examples of named modules. As a result, these examples currently can only be built with GCC. See the named-only branch for a subset of examples that only cover named modules and that have been modified to #include instead of import headers in order to be usable with other compilers (Clang, MSVC). See also the named-only-import-std branch which rather does import std.

This repository contains a number of examples that demonstrate various C++20 modules features and their support in build2. For a discussion of the demonstrated functionality see Complete C++20 Modules Support with GCC.

Note: requires GCC 12 or later.

hello-module -- module example

hello-partition -- module partition example

hello-header-import -- header unit importation example

hello-header-translate -- header include translation example

hello-library-module -- module library example

hello-library-header -- header importation/translation library example

hello-utility-library-module -- module utility library example

hello-simple -- module example as build2 simple project

While you can build each example individually (see README in each example for details), you can also build them all (except for hello-simple) at once in a shared build configuration, for example:

git clone https://github.com/build2/cxx20-modules-examples.git
cd cxx20-modules-examples

bdep init -C @gcc cc config.cxx=g++ config.cxx.translate_include=all-importable
bdep update @gcc