Skip to content

Commit 7f12bf4

Browse files
committed
edit pass: header-unit-walkthroughs
1 parent 534b738 commit 7f12bf4

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

docs/build/walkthrough-header-units.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,15 @@ You can define additional macros when you build the program that imports the hea
4040

4141
There are several ways to compile a file into a header unit:
4242

43-
- **Automatically scan for header units**. This approach is best suited to smaller projects that include many different header files. See [Walkthrough: Import STL libraries as header units](walkthrough-import-stl-header-units.md#approach1) for a demonstration of this approach. This approach is better suited to smaller projects. That's because it can't guarantee optimal build throughput since it scans all the files to find what should be built into header units.
43+
- **Automatically scan for header units**. This approach is best suited to smaller projects that include many different header files. See [Walkthrough: Import STL libraries as header units](walkthrough-import-stl-header-units.md#approach1) for a demonstration of this approach. This approach is better suited to smaller projects because it can't guarantee optimal build throughput. That's because it scans all the files to find what should be built into header units.
4444

4545
- **Build a shared header unit project**. This approach is best suited for larger projects and for when you want more control over the organization of the imported header units. You create a static library project (or projects) that contain the header units that you want. Then reference the library project (or projects) from the project that then imports the header units it needs. See [Walkthrough: Import STL libraries as header units](walkthrough-import-stl-header-units.md#approach2) for a demonstration of this approach.
4646

4747
- **Choose individual header units to build**. This approach gives you file-by-file control over which header files are treated as header units. It's also a good way to quickly and selectively try out header units in your project. This approach is demonstrated in this walkthrough.
4848

4949
## Convert a project to use header units
5050

51-
In this example, you'll compile a header file as a header unit. Begin by creating the following project in Visual Studio:
51+
In this example, you'll compile a header file as a header unit. Start by creating the following project in Visual Studio:
5252

5353
1. Create a new C++ console app project.
5454
1. Replace the source file content as follows:
@@ -72,9 +72,9 @@ In this example, you'll compile a header file as a header unit. Begin by creatin
7272
}
7373
```
7474

75-
To enable header units, first set the **C++ Language Standard** to [**/std:c++latest**](./reference/std-specify-language-standard-version.md):
75+
To enable header units, first set the **C++ Language Standard** to [**/std:c++latest**](./reference/std-specify-language-standard-version.md).
7676

77-
1. In the Visual Studio main menu, select **Project** > **Properties**.
77+
1. On the Visual Studio main menu, select **Project** > **Properties**.
7878
1. In the left pane of the project property pages window, select **Configuration Properties** > **General**.
7979
1. In the **C++ Language Standard** list, select **Preview - Features from the Latest C++ Working Draft (/std:c++latest)**:
8080
:::image type="content" source="media/set-cpp-language-latest.png" alt-text="Screenshot that shows setting the language standard to the preview version.":::
@@ -95,7 +95,7 @@ Set the **Compile As** property to **Compile as C++ Header Unit (/exportHeader)*
9595

9696
### Change your code to import a header unit
9797

98-
In the source file for the example project, that is, the file that contains `main()`, change `#include "Pythagorean.h"` to `import "Pythagorean.h"`. (Don't forget the trailing semicolon that is required for `import` statements.) When you're compiling a header unit from a system header, use angle brackets (`import <file>;`). If it's a project header, use `import "file";`.
98+
In the source file for the example project, that is, the file that contains `main()`, change `#include "Pythagorean.h"` to `import "Pythagorean.h"`. (Don't forget the trailing semicolon that's required for `import` statements.) When you're compiling a header unit from a system header, use angle brackets (`import <file>;`). If it's a project header, use `import "file";`.
9999

100100
Build the solution. (**Build** > **Build Solution** on the main menu.) Run it to see that it produces the expected output: `Pythagorean triple a:2 b:3 c:13`
101101

docs/build/walkthrough-import-stl-header-units.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@ helpviewer_keywords: ["import", "header unit", "ifc", "stl"]
1111

1212
This walkthrough shows two ways to import C++ Standard Template Library (STL) libraries as header units in Visual Studio.
1313

14-
The [first way](#approach1) has the build system automatically scan for and build header units based on the STL headers you import in your project.
14+
The [first way](#approach1) is to have the build system automatically scan for and build header units based on the STL headers you import in your project.
1515

16-
The [second way](#approach2) demonstrates how to build a static library project that contains header units for the STL headers you want to use and then reference that project to import the header units.
16+
The [second way](#approach2) is to build a static library project that contains header units for the STL headers you want to use and then reference that project to import the header units.
1717

1818
Importing an STL header as a header unit is a simpler alternative to [precompiled header files](creating-precompiled-header-files.md). Header units are easier to set up and use than a shared precompiled header file (PCH) but still provide similar performance benefits. Unlike a PCH, when a header unit changes, only it and its dependencies are rebuilt.
1919

20-
Before you can import an STL header, it must be compiled into a header unit. A header unit is a binary representation of a header file. A header unit ends with an `.ifc` extension.
20+
Before you can import an STL header, it must be compiled into a header unit. A header unit is a binary representation of a header file. A header unit ends with an .ifc extension.
2121

2222
An important difference between a header unit and a header file is that header units aren't affected by macro definitions. You can't `#define` a symbol that causes the header unit to behave differently when you import it. You can do that with a header file.
2323

0 commit comments

Comments
 (0)