Skip to content

Commit 990722c

Browse files
authored
Merge pull request #4684 from corob-msft/learn/corob/cpp-docs-4293
Doc `Compile As` property per Olga in 4293
2 parents 9c2749e + fb2eafa commit 990722c

File tree

5 files changed

+60
-23
lines changed

5 files changed

+60
-23
lines changed

docs/build/reference/c-cpp-prop-page.md

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: "C/C++ Project Properties (Visual Studio)"
33
description: "Reference guide to the Visual Studio Microsoft C/C++ project Property Pages properties."
4-
ms.date: 06/30/2022
4+
ms.date: 11/17/2022
55
ms.topic: "article"
66
f1_keywords: ["VC.Project.VCCLCompilerTool.AdditionalModuleDirectories", "VC.Project.VCCLCompilerTool.ScanSourceForModuleDependencies"]
77
ms.assetid: 16375038-4917-4bd0-9a2a-26343c1708b7
@@ -36,7 +36,7 @@ Specifies one or more header units to use to resolve names passed to an `import`
3636

3737
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.
3838

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.
4040

4141
### Translate Includes to Imports
4242

@@ -485,13 +485,16 @@ Select the default calling convention for your application (can be overridden by
485485

486486
### Compile As
487487

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.
489489

490490
#### Choices
491491

492492
- **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.
495498

496499
### Disable Specific Warnings
497500

docs/build/reference/headername.md

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: "/headerName (Build a header unit from the specified header)"
33
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
55
author: "tylermsft"
66
ms.author: "twhitney"
77
f1_keywords: ["/headerName"]
@@ -23,30 +23,32 @@ The name of a header file that the compiler should compile into a header unit (*
2323

2424
## Remarks
2525

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.
2727

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).
3030

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).
3335

3436
### Examples
3537

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:
3739

38-
```Bash
40+
```bash
3941
cl /std:c++latest /exportHeader /headerName:quote m.h /Fom.h.obj
4042
```
4143

42-
The `/headerName:{quote,angle}` option acts like a flag and doesn't need an argument. The following examples are valid:
44+
The **`/headerName:quote`** and **`/headerName:angle`** options act like a flag and don't need an argument. The following examples are valid:
4345

44-
```Bash
46+
```bash
4547
cl /std:c++latest /exportHeader /headerName:angle /MP /Fo.\ vector iostream algorithm
4648
cl /std:c++latest /exportHeader /headerName:quote /MP /Fo.\ my-utilities.h a/b/my-core.h
4749
```
4850

49-
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"`:
5052

5153
```bash
5254
cl /std:c++latest /exportHeader /headerName:angle /MP /Fo.\ vector iostream algorithm /headerName:quote my-utilities.h a/b/my-core.h
@@ -55,15 +57,15 @@ cl /std:c++latest /exportHeader /headerName:angle /MP /Fo.\ vector iostream algo
5557
### To set this compiler option in the Visual Studio development environment
5658

5759
> [!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.
5961
6062
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).
6163

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**.
6365

6466
1. Select the **Configuration Properties** > **C/C++** > **Command Line** property page.
6567

66-
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.
6769

6870
## See also
6971

docs/build/reference/interface.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: "/interface"
33
description: "Use the /interface compiler option to treat the input file as a module interface unit."
4-
ms.date: 04/15/2022
4+
ms.date: 11/16/2022
55
author: "tylermsft"
66
ms.author: "twhitney"
77
f1_keywords: ["/interface", "VC.Project.VCCLCompilerTool.Interface"]
@@ -32,6 +32,18 @@ This switch must be used in with the [`/TP` (Specify source file type)](tc-tp-tc
3232
**`/interface`** is available in Visual Studio 2019 version 16.10, or later.\
3333
**`/interface`** requires [/std:c++20](std-specify-language-standard-version.md) or later.
3434

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+
3547
## See also
3648

3749
[Overview of modules in C++](../../cpp/modules-cpp.md)\

docs/build/reference/internal-partition.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: "/internalPartition"
33
description: "Use the /internalPartition compiler option to treat the input file as an internal partition unit."
4-
ms.date: 06/29/2022
4+
ms.date: 11/16/2022
55
author: "tylermsft"
66
ms.author: "twhitney"
77
f1_keywords: ["/internalPartition", "VC.Project.VCCLCompilerTool.Interface"]
@@ -50,6 +50,18 @@ This option can't be used with the [`/interface`](interface.md) compiler option.
5050
**`/internalPartition`** is available in Visual Studio 2019 version 16.10, or later.\
5151
**`/internalPartition`** requires [/std:c++20](std-specify-language-standard-version.md) or later.
5252

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+
5365
## See also
5466

5567
[Overview of modules in C++](../../cpp/modules-cpp.md)\

docs/build/reference/module-exportheader.md

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,19 @@ cl . . . /std:c++latest /exportHeader /headerName:quote util/util.h
5353

5454
### To set this compiler option in the Visual Studio development environment
5555

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.
5765

5866
## See also
5967

60-
[`/headerName (Build a header unit from the specified header)`](headername.md)\
68+
[`/headerName` (Build a header unit from the specified header)](headername.md)\
6169
[`/headerUnit` (Use header unit IFC)](headerunit.md)\
6270
[`/reference` (Use named module IFC)](module-reference.md)\
6371
[`/translateInclude` (Translate include directives into import directives)](translateinclude.md)

0 commit comments

Comments
 (0)