You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
description: Use the import and export statements to access and to publish types and functions defined in the specified module.
6
+
description: Use import and export declarations to access and to publish types and functions defined in the specified module.
7
7
---
8
8
9
9
# module, import, export
10
10
11
-
The **module**, **import**, and **export**keywords are available in C++20 and require the [/experimental:module](../build/reference/experimental-module.md) compiler switch along with [/std:c++latest](../build/reference/std-specify-language-standard-version.md). For more information, see [Overview of modules in C++](modules-cpp.md).
11
+
The **module**, **import**, and **export**declarations are available in C++20 and require the [/experimental:module](../build/reference/experimental-module.md) compiler switch along with [/std:c++latest](../build/reference/std-specify-language-standard-version.md). For more information, see [Overview of modules in C++](modules-cpp.md).
12
12
13
13
## module
14
14
15
-
Use the**module**statement at the beginning of a module implementation file to specify that the file contents belong to the named module.
15
+
Place a**module**declaration at the beginning of a module implementation file to specify that the file contents belong to the named module.
16
16
17
17
```cpp
18
18
module ModuleA;
19
19
```
20
20
21
21
## export
22
22
23
-
Use the**export module**statement for the module's primary interface file, which must have extension **.ixx**:
23
+
Use an**export module**declaration for the module's primary interface file, which must have extension **.ixx**:
24
24
25
25
```cpp
26
26
exportmodule ModuleA;
@@ -55,11 +55,11 @@ void main() {
55
55
}
56
56
```
57
57
58
-
The **export** keyword may not appear in a module implementation file. When the **export** modifier is applied to a namespace name, all names in the namespace are exported.
58
+
The **export** keyword may not appear in a module implementation file. When **export** is applied to a namespace name, all names in the namespace are exported.
59
59
60
60
## import
61
61
62
-
Use the**import**statement to make a module's names visible in your program. The import statement must appear after the module statement and after any #include directives, but before any declarations in the file.
62
+
Use an**import**declaration to make a module's names visible in your program. The import declaration must appear after the module declaration and after any #include directives, but before any declarations in the file.
63
63
64
64
```cpp
65
65
module ModuleA;
@@ -77,21 +77,26 @@ class Baz
77
77
78
78
## Remarks
79
79
80
-
Both **import** and **module** are contextual keywords. They are treated as keywords only when they appear on one of these lines:
80
+
Both **import** and **module** are treated as keywords only when they appear at the start of a logical line:
description: Modules in C++20 provide a modern alternative to header files.
6
6
---
@@ -27,14 +27,14 @@ Although not specified by the C++20 standard, Microsoft enables its implementati
27
27
- std.threading provides the contents of headers \<atomic>, \<condition_variable>, \<future>, \<mutex>, \<shared_mutex>, and \<thread>
28
28
- std.core provides everything else in the C++ Standard Library
29
29
30
-
To consume these modules, just add an import statement to the top of the source code file. For example:
30
+
To consume these modules, just add an import declaration to the top of the source code file. For example:
31
31
32
32
```cpp
33
33
import std.core;
34
34
import std.regex;
35
35
```
36
36
37
-
To consume the Microsoft Standard Library module, you must compile your program with [/EHsc](../build/reference/eh-exception-handling-model.md) and [/MD](../build/reference/md-mt-ld-use-run-time-library.md) options.
37
+
To consume the Microsoft Standard Library module, compile your program with [/EHsc](../build/reference/eh-exception-handling-model.md) and [/MD](../build/reference/md-mt-ld-use-run-time-library.md) options.
38
38
39
39
## Basic example
40
40
@@ -57,7 +57,7 @@ namespace Bar
57
57
}
58
58
```
59
59
60
-
The file **MyProgram.cpp** uses the **import**statement to access the name that is exported by `Foo`. Note that the name `Bar` is visible here, but not all of its members. Also note that the macro `ANSWER` is not visible.
60
+
The file **MyProgram.cpp** uses the **import**declaration to access the name that is exported by `Foo`. Note that the name `Bar` is visible here, but not all of its members. Also note that the macro `ANSWER` is not visible.
0 commit comments