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
@@ -36,7 +36,7 @@ Specifies one or more header units to use to resolve names passed to an `import`
36
36
37
37
When set to **Yes**, the compiler scans all C++ sources, not just module interface and header unit sources, for module and header units dependencies. The build system builds the full dependencies graph, which ensures that all imported modules and header units are built before compiling the files that depend on them. When combined with **Translate Includes to Imports**, any header file that's specified in a [`header-units.json`](header-unit-json-reference.md) file in the same directory as the header file is compiled into a header unit.
38
38
39
-
Files that have the extension *`.ixx`*, and files that have their **File properties** > **C/C++** > **Compile As** property set to **Compile as C++ Header Unit (/export)**, are always scanned.
39
+
Files that have the extension *`.ixx`*, and files that have their **File properties** > **C/C++** > **Compile As** property set to **Compile as C++ Header Unit (/exportHeader)**, are always scanned.
40
40
41
41
### Translate Includes to Imports
42
42
@@ -485,13 +485,16 @@ Select the default calling convention for your application (can be overridden by
485
485
486
486
### Compile As
487
487
488
-
Select compile language option for *`.c`* and *`.cpp`*files. Sets [`/TC`, `/TP`](tc-tp-tc-tp-specify-source-file-type.md).
488
+
Select compile language option for source files. Sets [`/TC`, `/TP`](tc-tp-tc-tp-specify-source-file-type.md), [/interface](./interface.md), [`/internalPartition`](./internal-partition.md), or [`/exportHeader`](./module-exportheader.md) options.
489
489
490
490
#### Choices
491
491
492
492
-**Default** - Default.
493
-
-**Compile as C Code** - Compile as C Code.
494
-
-**Compile as C++ Code** - Compile as C++ Code.
493
+
-**Compile as C Code ([`/TC`](./tc-tp-tc-tp-specify-source-file-type.md))** - Compile specified source files as C code. By default, files with a *`.c`* extension are compiled as C.
494
+
-**Compile as C++ Code ([`/TP`](./tc-tp-tc-tp-specify-source-file-type.md))** - Compile specified source files as C++ code. By default, all source files that don't have a *`.c`*, *`.ixx`*, *`.cppm`*, *`.h`*, or no extension are compiled as C++.
495
+
-**Compile as C++ Module Code ([`/interface`](./interface.md))** - Compile specified source files as C++ module code. By default, files with a *`.ixx`* or *`.cppm`* extension are compiled as C++ module code.
496
+
-**Compile as C++ Module Internal Partition ([`/internalPartition`](./internal-partition.md))** - Compile specified source files as C++ module internal partition.
497
+
-**Compile as C++ Header Unit ([`/exportHeader`](./module-exportheader.md))** - Compile specified source files as C++ header unit. By default, files with a *`.h`* extension or no extension are compiled as header units.
Copy file name to clipboardExpand all lines: docs/build/reference/headername.md
+16-14Lines changed: 16 additions & 14 deletions
Original file line number
Diff line number
Diff line change
@@ -1,7 +1,7 @@
1
1
---
2
2
title: "/headerName (Build a header unit from the specified header)"
3
3
description: "Use the /headerName compiler option to establish a mapping between a header file and the header unit to build."
4
-
ms.date: 04/21/2022
4
+
ms.date: 11/16/2022
5
5
author: "tylermsft"
6
6
ms.author: "twhitney"
7
7
f1_keywords: ["/headerName"]
@@ -23,30 +23,32 @@ The name of a header file that the compiler should compile into a header unit (*
23
23
24
24
## Remarks
25
25
26
-
The **`/headerName`** compiler option is available starting in Visual Studio 2019 version 16.10.
26
+
The **`/headerName:quote`**and **`/headerName:angle`**compiler options are available starting in Visual Studio 2019 version 16.10.
27
27
28
-
The **`/headerName`** compiler option, in all its forms, requires the [`/std:c++20`](std-specify-language-standard-version.md) or later compiler option (such as **`/std:c++latest`**).\
29
-
If you specify **`/headerName:{quote,angle}`**, you must also specify [`/exportHeader`](module-exportheader.md).
28
+
The **`/headerName`** compiler options, in all their forms, require the [`/std:c++20`](std-specify-language-standard-version.md) or later compiler option (such as **`/std:c++latest`**).\
29
+
If you specify a **`/headerName`** option, you must also specify [`/exportHeader`](module-exportheader.md).
30
30
31
-
**`/headerName:quote`** looks up *`header-filename`* using the same rules as `#include "header-name"` and builds it as a header unit (*`.ifc`* file).\
32
-
**`/headerName:angle`** looks up *`header-filename`* using the same rules as `#include <header-name>` and builds it as a header unit (*`.ifc`* file).
31
+
-**`/headerName:quote`** looks up *`header-filename`* using the same rules as `#include "header-filename"` and builds it as a header unit (*`.ifc`* file).
32
+
-**`/headerName:angle`** looks up *`header-filename`* using the same rules as `#include <header-filename>` and builds it as a header unit (*`.ifc`* file).
33
+
34
+
For more information about the path searching rules for included files in quotes or angle brackets, see [`#include` directive](../../preprocessor/hash-include-directive-c-cpp.md).
33
35
34
36
### Examples
35
37
36
-
Given a project that references a header file it defines called `m.h`, the compiler option to compile it into a header unit looks similar to this:
38
+
Given a project that references a header file it defines called *`m.h`*, the compiler option to compile it into a header unit looks similar to this example:
You can specify multiple `/headerName` options on the same command line, and every argument after that option will be processed with the specified *`header-filename`* lookup rules. The following example processes all the headers as the previous two command line examples in the same way. It looks up the headers using the lookup rules applied as if they had been specified as: `#include <vector>`, `#include "my-utilties.h"`, and `#include "a/b/my-core.h"`:
51
+
You can specify multiple **`/headerName`** options on the same command line. Every argument after a **`/headerName`**option is processed with the specified include file lookup rules for quotes or angle brackets until the next **`/headerName`** option. The following example processes all the headers as the previous two command line examples in the same way as before. It looks up the headers using the lookup rules applied as if they had been specified as: `#include <vector>`, `#include <iostream>`, `#include <algorithm>`, `#include "my-utilties.h"`, and `#include "a/b/my-core.h"`:
### To set this compiler option in the Visual Studio development environment
56
58
57
59
> [!NOTE]
58
-
> Users don't typically set this command line option. It's set by the build system.
60
+
> You normally shouldn't set this option in the Visual Studio development environment. It's set by the build system.
59
61
60
62
1. Open the project's **Property Pages** dialog box. For details, see [Set C++ compiler and build properties in Visual Studio](../working-with-project-properties.md).
61
63
62
-
1. Set the **Configuration** drop-down to **All Configurations**.
64
+
1. Set the **Configuration** drop-down to **All Configurations**. Set the **Platform** drop-down to **All Platforms**.
1. Modify the **Additional Options** property to add the *`/headerName`* options and arguments. Then, choose **OK** or **Apply** to save your changes.
68
+
1. Modify the **Additional Options** property to add the *`/headerName:quote`*or *`/headerName:angle`*options and the header filenames the options apply to. Then, choose **OK** or **Apply** to save your changes.
@@ -32,6 +32,18 @@ This switch must be used in with the [`/TP` (Specify source file type)](tc-tp-tc
32
32
**`/interface`** is available in Visual Studio 2019 version 16.10, or later.\
33
33
**`/interface`** requires [/std:c++20](std-specify-language-standard-version.md) or later.
34
34
35
+
### To set this compiler option in the Visual Studio development environment
36
+
37
+
You normally shouldn't set this option in the Visual Studio development environment unless you use a different extension for your module interface files. By default, the build system applies this option to files that have a *`.ixx`** extension.
38
+
39
+
1. To apply the **`/interface`** option to a file explicitly in the IDE, select the file in **Solution Explorer**. Right-click to open the context menu and select **Properties** to open the Property Pages dialog.
40
+
41
+
1. Set the **Configuration** dropdown to **All Configurations**. Set the **Platform** dropdown to **All Platforms**.
42
+
43
+
1. Open the **Configuration Properties** > **C/C++** > **Advanced** property page.
44
+
45
+
1. Use the dropdown control to modify the **Compile As** property to **Compile as C++ Module Code (/interface)**. Choose **OK** or **Apply** to save your changes.
46
+
35
47
## See also
36
48
37
49
[Overview of modules in C++](../../cpp/modules-cpp.md)\
@@ -50,6 +50,18 @@ This option can't be used with the [`/interface`](interface.md) compiler option.
50
50
**`/internalPartition`** is available in Visual Studio 2019 version 16.10, or later.\
51
51
**`/internalPartition`** requires [/std:c++20](std-specify-language-standard-version.md) or later.
52
52
53
+
### To set this compiler option in the Visual Studio development environment
54
+
55
+
You normally shouldn't set this option in the Visual Studio development environment unless you use a different extension for your partition files. By default, the build system applies this option to files that have a *`.ixx`** extension.
56
+
57
+
1. To apply the **`/internalPartition`** option to a file explicitly in the IDE, select the file in **Solution Explorer**. Right-click to open the context menu and select **Properties** to open the Property Pages dialog.
58
+
59
+
1. Set the **Configuration** dropdown to **All Configurations**. Set the **Platform** dropdown to **All Platforms**.
60
+
61
+
1. Open the **Configuration Properties** > **C/C++** > **Advanced** property page.
62
+
63
+
1. Use the dropdown control to modify the **Compile As** property to **Compile as C++ Module Internal Partition (/internalPartition)**. Choose **OK** or **Apply** to save your changes.
64
+
53
65
## See also
54
66
55
67
[Overview of modules in C++](../../cpp/modules-cpp.md)\
### To set this compiler option in the Visual Studio development environment
55
55
56
-
You normally shouldn't set this in the Visual Studio development environment. It is set by the build system.
56
+
You normally shouldn't set this option in the Visual Studio development environment unless you use a different extension for your header files. By default, the build system applies this option to compiled files that have a *`.h`* extension, or no extension.
57
+
58
+
1. To apply the **`/exportHeader`** option to a file explicitly in the IDE, select the file in **Solution Explorer**. Right-click to open the context menu and select **Properties** to open the Property Pages dialog.
59
+
60
+
1. Set the **Configuration** dropdown to **All Configurations**. Set the **Platform** dropdown to **All Platforms**.
61
+
62
+
1. Open the **Configuration Properties** > **C/C++** > **Advanced** property page.
63
+
64
+
1. Use the dropdown control to modify the **Compile As** property to **Compile as C++ Header Unit (/exportHeader)**. Choose **OK** or **Apply** to save your changes.
57
65
58
66
## See also
59
67
60
-
[`/headerName (Build a header unit from the specified header)`](headername.md)\
68
+
[`/headerName` (Build a header unit from the specified header)](headername.md)\
61
69
[`/headerUnit` (Use header unit IFC)](headerunit.md)\
62
70
[`/reference` (Use named module IFC)](module-reference.md)\
63
71
[`/translateInclude` (Translate include directives into import directives)](translateinclude.md)
0 commit comments