# Support for C++20 Modules

[Modules](https://en.cppreference.com/w/cpp/language/modules) were introduced in the [C++20](https://en.cppreference.com/w/cpp/20) standard. They work as alternative to some use cases of header files and help share declarations and definitions across translation units.

> **Tip:**
> For now, CLion does not consider `.cpp` files to be modules, so it's recommended that you use other extensions (for example, `.cppm`).

CLion collects information from `.ixx`, `.cppm`, and `.mxx` files, parses `export module {name}` statements and creates mappings between `{name}` and module filenames. Then, the mappings are passed to the [Clangd engine](settings-languages-cpp-clangd.html) and used to provide coding assistance and highlighting.

If you update the module’s code or rename the module, CLion will automatically parse the changes. The information collected from modules is preserved between the IDE restarts.

CLion's support for modules has been tested in the following environments:

* CMake, Ninja generator, Visual Studio C++ toolchain.

* CMake, Visual Studio generator, Visual Studio C++ toolchain.

* CMake, Clang toolchain with compiler flags.

> **Tip:**
> For more information about project configuration, refer to [CMake generators](cmake-profile.html#cmake-generators), [MSVC](quick-tutorial-on-configuring-clion-on-windows.html#MSVC), [Compilers](how-to-switch-compilers-in-clion.html) , and [Quick CMake tutorial](quick-cmake-tutorial.html).

## Code insight for Modules

* CLion highlights module keywords (`import`, `export`, and `module`): ![Modules keywords highlighting](https://resources.jetbrains.com/help/img/idea/2026.2/cl_modules_highlight.png)

* Completion works for symbols from modules: ![Completion for symbols from modules](https://resources.jetbrains.com/help/img/idea/2026.2/cl_modules_completion.png)

* You can navigate between declarations and definitions of symbols from modules using `Ctrl+B` (Windows), `⌘ B` (macOS), `⌘ B` (IntelliJ IDEA Classic (macOS)), `⌘ B` (macOS System Shortcuts), `Ctrl+B` (XWin), `Ctrl+B` (GNOME), `Ctrl+B` (KDE), `Ctrl+Alt+G` (Emacs), `F12` (Sublime Text), `F12` (Sublime Text (macOS)), `⌘ Click` (Xcode), `F12` (Visual Studio), `F12` (Visual Studio (macOS)), `Ctrl+B` (ReSharper), `⌘ B` (ReSharper (macOS)), `F2` (QtCreator), `F2` (QtCreator (macOS)), `Ctrl+B` (NetBeans), `F3` (Eclipse), `F3` (Eclipse (macOS)): ![Navigation for modules](https://resources.jetbrains.com/help/img/idea/2026.2/cl_modules_navigation.animated.gif)

* [Find Usages](find-highlight-usages.html) and [refactorings](refactoring-source-code.html) are available inside modules. There are also early versions of the [Rename](rename-refactorings.html), [Change Signature](change-signature.html) , and [Extract](extract-method.html) refactorings that work across module boundaries (for now, they only work for files opened in CLion).

## Adding modules

In CLion, you can add new modules to your project automatically.

Procedure:

1. In the project tree, right-click the folder where you want to add a module and select `New | C++ Module Interface Unit`:

![New module menu](https://resources.jetbrains.com/help/img/idea/2026.2/cl_newmodules_menu.png)

2. Specify the module name, its type (extension), and whether you want CLion to add the newly created module to an existing CMake target:

![New module dialog](https://resources.jetbrains.com/help/img/idea/2026.2/cl_newmodule_dialog.png)

3. A new module will be created in your project tree and added to the `CMakeLists.txt` script if you chose that option:

![New module created](https://resources.jetbrains.com/help/img/idea/2026.2/cl_newmodule_results.png)

You can edit the template that CLion uses when creating module files in `Settings | Editor | File and Code Templates`:

![C++ Module file template settings](https://resources.jetbrains.com/help/img/idea/2026.2/cl_newmodule_codestule_Settings.png)

## See also

### External Links

[isocpp.org: articles tagged with 'Modules'](https://isocpp.org/blog/tag/modules) [CLion blog: announcement of modules support](https://blog.jetbrains.com/clion/2022/10/clion-2022-3-eap-cpp20-modules-now-supported/) [Modules description at ccpreference.com](https://en.cppreference.com/w/cpp/language/modules)

### Procedures

[Clangd settings](settings-languages-cpp-clangd.html) [C++ keywords completion](c-keywords-completion.html)

