Skip to content

Commit ea6beb8

Browse files
committed
use the modern way
1 parent af21fc1 commit ea6beb8

File tree

5 files changed

+19
-23
lines changed

5 files changed

+19
-23
lines changed

docs/build/reference/experimental-module.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ Enables compiler support for Microsoft's experimental form of C++ Standard modul
1515
1616
## Remarks
1717

18-
This switch was for the time before the new, standardized, way of consuming the C++ Standard Library as modules described in [Import the C++ standard library using modules](../../cpp/tutorial-import-stl-named-module.md) was available. Although you can use this switch to use the older experimental named modules, we recommend that you use the new, standardized, way of consuming the C++ Standard Library as modules described in [Import the C++ standard library using modules](../../cpp/tutorial-import-stl-named-module.md).
18+
This switch applies to the time before the new, standardized, way of consuming the C++ Standard Library as modules was available. Although you can use this switch to use the older experimental named modules, we recommend that you use the new, standardized, way of consuming the C++ Standard Library as modules described in [Import the C++ standard library using modules](../../cpp/tutorial-import-stl-named-module.md).
1919

20-
This compiler became available starting in Visual Studio 2015 Update 1. Ensure that **C++ Modules for v143 build tools (x64/x86 - experimental)** in selected the VS Installer. It's available in the **Individual components** tab of the installer. Search for **experimental** to see the option. For more information, see [Install C and C++ support in Visual Studio](../vscpp-step-0-installation.md).
20+
This compiler switch is available starting in Visual Studio 2015 Update 1. In the VS Installer under the **Individual components** tab, ensure that **C++ Modules for v143 build tools (x64/x86 - experimental)** in selected. You can use the search box with **experimental** to find it. For more information, see [Install C and C++ support in Visual Studio](../vscpp-step-0-installation.md).
2121

2222
| Version | Status |
2323
|---|---|
@@ -54,6 +54,7 @@ For more information about how to use and create modules, see [Overview of modul
5454

5555
## See also
5656

57+
[Import the C++ standard library using modules](../../cpp/tutorial-import-stl-named-module.md)\
5758
[`/headerUnit` (Use header unit IFC)](headerunit.md)\
5859
[`/exportHeader` (Create header units)](module-exportheader.md)\
5960
[`/reference` (Use named module IFC)](module-reference.md)\

docs/build/reference/scandependencies.md

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,8 @@ Consider the following sample code:
6060
#include <vector>
6161

6262
import other.module;
63-
import std.core;
64-
63+
import std;
6564
import "t.h";
66-
6765
import <iostream>;
6866

6967
int main() {}
@@ -83,14 +81,14 @@ The compiler produces a JSON file, *`output.json`*, with content similar to:
8381
{
8482
"primary-output": "app.obj",
8583
"outputs": [
86-
"C:\\Users\\username\\source\\repos\\app\\app"
84+
"output.json"
8785
],
8886
"requires": [
8987
{
9088
"logical-name": "other.module"
9189
},
9290
{
93-
"logical-name": "std.core"
91+
"logical-name": "std"
9492
},
9593
{
9694
"logical-name": "t.h",

docs/build/reference/sourcedependencies-directives.md

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,8 @@ Given the following sample code:
5959
#include <vector>
6060

6161
import m;
62-
import std.core;
63-
62+
import std;
6463
import <utility>;
65-
6664
import "t.h";
6765

6866
int main() {}
@@ -78,15 +76,16 @@ produces a JSON file *`output.json`* similar to:
7876
{
7977
"Version":"1.1",
8078
"Data":{
81-
"Source":"C:\\a\\b\\main.cpp",
79+
"Source":"C:\\test\\main.cpp",
8280
"ProvidedModule":"",
8381
"ImportedModules":[
8482
"m",
85-
"std.core"
83+
"std"
8684
],
8785
"ImportedHeaderUnits":[
8886
"C:\\...\\utility",
89-
"C:\\a\\b\\t.h"
87+
"C:\\...\\vector",
88+
"C:\\test\\t.h"
9089
]
9190
}
9291
}

docs/cpp/import-export-module.md

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ description: Use import and export declarations to access and to publish types a
77
---
88
# `module`, `import`, `export`
99

10-
The **`module`**, **`import`**, and **`export`** declarations are available in C++20 and require the compiler switch [`/std:c++20`](../build/reference/std-specify-language-standard-version.md) or later (such as **`/std:c++latest`**). For more information, see [Overview of modules in C++](modules-cpp.md).
10+
The **`module`**, **`import`**, and **`export`** declarations are available in C++20 and require the compiler switch [`/std:c++20`](../build/reference/std-specify-language-standard-version.md) or later. For more information, see [Overview of modules in C++](modules-cpp.md).
1111

1212
## `module`
1313

@@ -43,8 +43,6 @@ namespace ModuleA_NS
4343
Non-exported names aren't visible to code that imports the module:
4444

4545
```cpp
46-
//MyProgram.cpp
47-
4846
import ModuleA;
4947

5048
int main() {
@@ -64,9 +62,8 @@ Use an **`import`** declaration to make a module's names visible in your program
6462
module ModuleA;
6563

6664
#include "custom-lib.h"
67-
import std.core;
68-
import std.regex;
69-
import ModuleB;
65+
import std;
66+
import myModule;
7067

7168
// begin declarations here:
7269
template <class T>

docs/cpp/modules-cpp.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: "Overview of modules in C++"
33
description: Modules in C++20 provide a modern alternative to header files.
4-
ms.date: 02/11/2025
4+
ms.date: 04/17/2025
55
helpviewer_keywords: ["modules [C++]", "modules [C++], overview"]
66
---
77
# Overview of modules in C++
@@ -48,8 +48,8 @@ The file *`MyProgram.cpp`* uses **`import`** to access the name exported by `Exa
4848

4949
```cpp
5050
// MyProgram.cpp
51+
import std;
5152
import Example;
52-
import std.core;
5353

5454
using namespace std;
5555

@@ -156,7 +156,7 @@ You can include header files in a module source file by putting an `#include` di
156156
#include "customlib.h"
157157
#include "anotherlib.h"
158158

159-
import std.core;
159+
import std;
160160
import MyModuleB;
161161

162162
//... rest of file
@@ -166,7 +166,7 @@ You can use a traditional header file to control which modules are imported:
166166

167167
```cpp
168168
// MyProgram.h
169-
import std.core;
169+
import std;
170170
#ifdef DEBUG_LOGGING
171171
import std.filesystem;
172172
#endif
@@ -183,6 +183,7 @@ import "myheader.h";
183183

184184
## See also
185185

186+
[Tutorial: Import the C++ standard library using modules from the command line](tutorial-import-stl-named-module)\
186187
[`module`, `import`, `export`](import-export-module.md)\
187188
[Named modules tutorial](tutorial-named-modules-cpp.md)\
188189
[Compare header units, modules, and precompiled headers](../build/compare-inclusion-methods.md)

0 commit comments

Comments
 (0)