C++20 Modules
clice builds the modules a file imports when it compiles the file, so module units and their importers work like any other source: hover, navigation and completion reach across import. The feature pages show what each feature does in module units; this page shows the modules themselves.
Imports
A file that imports a module sees the names the module exports, and those of the modules it re-exports.
Imported symbols
A name imported from a module reads its declaration on hover, in a file that imports the module
The importing file compiles against the module's interface, which clice builds when the file opens; nothing else needs to be open.
Re-exported modules
A module that re-exports another with export import gives its importers the names of both
Exports
A declaration is exported on its own, in an export block, or as a member of an export namespace.
Export blocks and namespaces
An export { … } block exports every declaration inside it, and export namespace every member of the namespace
Module Units
A module can be split into partitions, and a unit can include headers in its global module fragment.
Module partitions
A module split into partitions gives its importers what every partition its primary interface re-exports declares
A partition imports a sibling by its partition name alone, import :Types;, and the primary interface uses what its partitions declare.
Global module fragment
A module unit includes headers in its global module fragment, ahead of the module declaration, and imports modules after it
A module unit compiled once
A module unit is compiled once, into the module file its importers read, and that compile indexes it too
The build of the module file merges the unit's index into the project's, which the background index then finds current, and a file importing the module completes the names the module exports from the module file its compile loads.
Module units built by cl
A project built by cl, with CMake or MSBuild, gets its modules built like any other, its .ixx interfaces included
What a unit is comes from its module declaration, whatever its suffix; the interface files cl writes and reads are left to the build.
Edits
An edit to a module interface reaches its importers once it is saved.
Interface edits reach importers
An importer sees what its module's interface declares once the interface is saved, not while the edit is unsaved
Build Failures
A module that fails to build reports its errors, and the files importing it report the import.
Broken modules
A module that fails to build reports its own errors, and the files importing it say why it did not build
Known Limitations
- Header units.
import "util.h";andimport <util.h>;are not supported. Each such import is an error saying so, and nothing the header declares is visible after it; include the header instead.
