Content deleted Content added
No edit summary Tags: Mobile edit Mobile app edit iOS app edit App section source |
No edit summary Tags: Mobile edit Mobile app edit iOS app edit App section source |
||
Line 484:
</ref> Modules in C++ compile faster and link faster than traditional headers,<ref>{{cite web|url=https://learn.microsoft.com/en-us/cpp/build/compare-inclusion-methods?view=msvc-170|title=Overview of modules in C++|date=12 February 2022 |publisher=Microsoft}}</ref> and eliminate the necessity of [[include guard|{{mono|#include}} guards]] or [[pragma once|{{mono|#pragma once}}]]. Until C++26, <code>import</code>, <code>export</code>, and <code>module</code> keywords were partially handled by the preprocessor.
For code bases that cannot migrate to modules immediately, C++ also offers "header units" as a feature, which allows header files to be imported in the same way a module would. Unlike modules, header units may emit macros, offering minimal breakage between migration. Header units are designed to be a transitional solution before totally migrating to modules.<ref>{{cite web|url=https://learn.microsoft.com/en-us/cpp/build/walkthrough-header-units?view=msvc-170|title=Walkthrough: Build and import header units in Microsoft Visual C++|date=12 April 2022 |publisher=Microsoft}}</ref> For instance, one may write <syntaxhighlight lang="C++" inline>import <string>;</syntaxhighlight> instead of <syntaxhighlight lang="C++" inline>#include <string></syntaxhighlight>, or <syntaxhighlight lang="C++" inline>import "MyHeader.hpp";</syntaxhighlight> instead of <syntaxhighlight lang="C++" inline>#include "MyHeader.hpp"</syntaxhighlight>.
== See also ==
|