Skip to content

Commit 4c52a71

Browse files
authored
Merge pull request #4015 from MicrosoftDocs/main637922167238454474
Repo sync for protected CLA branch
2 parents cfc44a6 + 7a30aef commit 4c52a71

File tree

38 files changed

+821
-457
lines changed

38 files changed

+821
-457
lines changed

docs/build/clang-support-msbuild.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
description: "Learn more about: Clang/LLVM support in Visual Studio projects"
33
title: "Clang/LLVM support in Visual Studio projects"
4-
ms.date: 11/11/2021
4+
ms.date: 06/29/2022
55
ms.description: "Configure a Visual Studio MSBuild project to use the Clang/LLVM toolchain."
66
helpviewer_keywords: ["Clang support for C++ MSBuild projects"]
77
---
@@ -35,7 +35,7 @@ To configure a Visual Studio project to use Clang, right-click on the project no
3535

3636
If you're using the Clang tools that are bundled with Visual Studio, no extra steps are required. For Windows projects, Visual Studio by default invokes Clang in [clang-cl](https://llvm.org/devmtg/2014-04/PDFs/Talks/clang-cl.pdf) mode. It links with the Microsoft implementation of the Standard Library. By default, **clang-cl.exe** is located in *%VCINSTALLDIR%\\Tools\\Llvm\\bin\\* and *%VCINSTALLDIR%\\Tools\\Llvm\\x64\\bin\\*.
3737

38-
If you're using a custom Clang installation, you can either modify **Project** > **Properties** > **VC++ Directories** > **Configuration Properties** > **Executable Directories** by adding the custom Clang installation root as the first directory there, or change the value of the `LLVMInstallDir` property. For more information, see [Set a custom LLVM location](#custom_llvm_location).
38+
If you're using a custom Clang installation, you can change the value of the `LLVMInstallDir` property. For more information, see [Set a custom LLVM location](#custom_llvm_location).
3939

4040
## Configure a Linux project to use Clang tools
4141

docs/build/creating-precompiled-header-files.md

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
description: "Learn more about: Precompiled header files"
33
title: "Precompiled Header Files"
4-
ms.date: 03/02/2022
4+
ms.date: 06/29/2022
55
helpviewer_keywords: ["precompiled header files, creating", "PCH files, creating", "cl.exe compiler, precompiling code", ".pch files, creating"]
66
ms.assetid: e2cdb404-a517-4189-9771-c869c660cb1b
77
---
@@ -34,9 +34,9 @@ You can precompile both C and C++ programs. In C++ programming, it's common prac
3434

3535
You can precompile any C or C++ code; you're not limited to precompiling only header files.
3636

37-
Precompiling requires planning, but it offers significantly faster compilations if you precompile source code other than simple header files.
37+
Precompiling requires planning, but it offers much faster compilations if you precompile source code other than simple header files.
3838

39-
Precompile code when you know that your source files use common sets of header files but don't include them in the same order, or when you want to include source code in your precompilation.
39+
Precompile code when you know that your source files use common sets of header files, or when you want to include source code in your precompilation.
4040

4141
The precompiled-header options are [`/Yc` (Create Precompiled Header File)](reference/yc-create-precompiled-header-file.md) and [`/Yu` (Use Precompiled Header File)](reference/yu-use-precompiled-header-file.md). Use **`/Yc`** to create a precompiled header. When used with the optional [`hdrstop`](../preprocessor/hdrstop.md) pragma, **`/Yc`** lets you precompile both header files and source code. Select **`/Yu`** to use an existing precompiled header in the existing compilation. You can also use **`/Fp`** with the **`/Yc`** and **`/Yu`** options to provide an alternative name for the precompiled header.
4242

@@ -50,7 +50,7 @@ Because PCH files contain information about the machine environment and memory a
5050

5151
The [`/Yu`](reference/yu-use-precompiled-header-file.md) compiler option lets you specify which PCH file to use.
5252

53-
When you use a PCH file, the compiler assumes the same compilation environment (one that uses consistent compiler options, pragmas, and so on) that was in effect when you created the PCH file, unless you specify otherwise. If the compiler detects an inconsistency, it issues a warning and identifies the inconsistency where possible. Such warnings don't necessarily indicate a problem with the PCH file; they simply warn you of possible conflicts. Consistency requirements for PCH files are described in the following sections.
53+
When you use a PCH file, the compiler assumes the same compilation environment that was in effect when you created the PCH file, unless you specify otherwise. The compilation environment includes the compiler options, pragmas, and so on. If the compiler detects an inconsistency, it issues a warning and identifies the inconsistency where possible. Such warnings don't necessarily indicate a problem with the PCH file; they simply warn you of possible conflicts. Consistency requirements for PCH files are described in the following sections.
5454

5555
### Compiler option consistency
5656

@@ -144,7 +144,7 @@ This table lists compiler options that might trigger an inconsistency warning wh
144144
| **`/D `**| Define constants and macros | Must be the same between the compilation that created the precompiled header and the current compilation. The state of defined constants isn't checked. However, unpredictable results can occur if your files depend on the values of the changed constants. |
145145
| **`/E`** or **`/EP`** | Copy preprocessor output to standard output | Precompiled headers don't work with the **`/E`** or **`/EP`** option. |
146146
| **`/Fr`** or **`/FR`** | Generate Microsoft Source Browser information | For the **`/Fr`** and **`/FR`** options to be valid with the **`/Yu`** option, they must also have been in effect when the precompiled header was created. Subsequent compilations that use the precompiled header also generate Source Browser information. Browser information is placed in a single *`.sbr`* file and is referenced by other files in the same manner as CodeView information. You can't override the placement of Source Browser information. |
147-
| **`/GA`**, **`/GD`**, **`/GE`**, **`/Gw`**, or **`/GW`** | Windows protocol options | Must be the same between the compilation that created the precompiled header and the current compilation. If these options differ, a warning message results. |
147+
| **`/GA`**, **`/GD`**, **`/GE`**, **`/Gw`**, or **`/GW`** | Windows protocol options | Must be the same between the compilation that created the precompiled header and the current compilation. The compiler emits a warning if these options differ. |
148148
| **`/Zi`** | Generate complete debugging information | If this option is in effect when the precompiled header is created, subsequent compilations that use the precompilation can use that debugging information. If **`/Zi`** isn't in effect when the precompiled header is created, subsequent compilations that use the precompilation and the **`/Zi`** option trigger a warning. The debugging information is placed in the current object file, and local symbols defined in the precompiled header aren't available to the debugger. |
149149

150150
> [!NOTE]
@@ -158,7 +158,7 @@ For another approach to using the manual precompiled-header options in a project
158158

159159
## PCH files in the build process
160160

161-
The code base of a software project is often contained in multiple C or C++ source files, object files, libraries, and header files. Typically, a makefile coordinates the combination of these elements into an executable file. The following figure shows the structure of a makefile that uses a precompiled header file. The NMAKE macro names and the file names in this diagram are consistent with the ones in the example code found in [Sample makefile for PCH](#sample-makefile-for-pch) and [Example code for PCH](#example-code-for-pch).
161+
The code base of a software project is often contained in multiple C or C++ source files, object files, libraries, and header files. Typically, a makefile coordinates the combination of these elements into an executable file. The following figure shows the structure of a makefile that uses a precompiled header file. The NMAKE macro names and the file names in this diagram are consistent with the example code found in [Sample makefile for PCH](#sample-makefile-for-pch) and [Example code for PCH](#example-code-for-pch).
162162

163163
The figure uses three diagrammatic devices to show the flow of the build process. Named rectangles represent each file or macro; the three macros represent one or more files. Shaded areas represent each compile or link action. Arrows show which files and macros are combined during the compilation or linking process.
164164

@@ -248,6 +248,8 @@ For more information on makefiles, see [NMAKE reference](reference/nmake-referen
248248

249249
The following source files are used in the makefile described in [PCH files in the build process](#pch-files-in-the-build-process) and [Sample makefile for PCH](#sample-makefile-for-pch). The comments contain important information.
250250

251+
Source file `ANOTHER.H`:
252+
251253
```cpp
252254
// ANOTHER.H : Contains the interface to code that is not
253255
// likely to change.
@@ -259,6 +261,8 @@ void savemoretime( void );
259261
#endif // __ANOTHER_H
260262
```
261263

264+
Source file `STABLE.H`:
265+
262266
```cpp
263267
// STABLE.H : Contains the interface to code that is not likely
264268
// to change. List code that is likely to change
@@ -271,6 +275,8 @@ void savetime( void );
271275
#endif // __STABLE_H
272276
```
273277

278+
Source file `UNSTABLE.H`:
279+
274280
```cpp
275281
// UNSTABLE.H : Contains the interface to code that is
276282
// likely to change. As the code in a header
@@ -285,6 +291,8 @@ void notstable( void );
285291
#endif // __UNSTABLE_H
286292
```
287293

294+
Source file `APPLIB.CPP`:
295+
288296
```cpp
289297
// APPLIB.CPP : This file contains the code that implements
290298
// the interface code declared in the header
@@ -310,6 +318,8 @@ void notstable( void )
310318
}
311319
```
312320
321+
Source file `MYAPP.CPP`:
322+
313323
```cpp
314324
// MYAPP.CPP : Sample application
315325
// All precompiled code other than the file listed

docs/build/reference/external-external-headers-diagnostics.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: "/external (External headers diagnostics)"
33
description: "The Microsoft C++ compiler /external headers diagnostic options syntax and usage."
4-
ms.date: 02/17/2022
4+
ms.date: 06/29/2022
55
f1_keywords: ["/external", "/external:anglebrackets", "/external:env:", "/external:I", "/external:W0", "/external:W1", "/external:W2", "/external:W3", "/external:W4", "/external:templates-", "/experimental:external", "VC.Project.VCCLCompilerTool.ExternalDirectoriesEnv", "VC.Project.VCCLCompilerTool.ExternalIncludeDirectories", "VC.Project.VCCLCompilerTool.ExternalWarningLevel", "VC.Project.VCCLCompilerTool.TreatExternalTemplatesAsInternal"]
66
helpviewer_keywords: ["/external compiler option [C++]", "-external compiler option [C++]", "external compiler option [C++]"]
77
---
@@ -68,6 +68,8 @@ All the existing mechanisms to enable, disable, and suppress warnings still work
6868

6969
This sample program has two source files, *`program.cpp`* and *`header_file.h`*. The *`header_file.h`* file is in an *`include_dir`* subdirectory of the directory containing the *`program.cpp`* file:
7070

71+
Source file `include_dir/header_file.h`:
72+
7173
```cpp
7274
// External header: include_dir/header_file.h
7375

@@ -79,6 +81,8 @@ struct sample_struct
7981
};
8082
```
8183

84+
Source file `program.cpp`:
85+
8286
```cpp
8387
// User code: program.cpp
8488
#include <header_file.h>

docs/build/reference/gh-enable-penter-hook-function.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: "/Gh (Enable _penter hook function)"
33
description: "Describes the /Gh compiler option to call the supplied _penter function."
4-
ms.date: "07/06/2020"
4+
ms.date: 06/29/2022
55
f1_keywords: ["_penter"]
66
helpviewer_keywords: ["/Gh compiler option [C++]", "Gh compiler option [C++]", "_penter function", "-Gh compiler option [C++]"]
77
ms.assetid: 1510a082-8a0e-486e-a309-6add814b494f
@@ -42,6 +42,8 @@ This declaration isn't available for 64-bit projects.
4242
4343
The following code, when compiled with **/Gh**, shows how `_penter` is called twice; once when entering function `main` and once when entering function `x`. The example consists of two source files, which you compile separately.
4444
45+
Source file `local_penter.cpp`:
46+
4547
```cpp
4648
// local_penter.cpp
4749
// compile with: cl /EHsc /c local_penter.cpp
@@ -74,6 +76,8 @@ extern "C" void __declspec(naked) __cdecl _penter( void ) {
7476
}
7577
```
7678

79+
Source file `Gh_compiler_option.cpp`:
80+
7781
```cpp
7882
// Gh_compiler_option.cpp
7983
// compile with: cl /EHsc /Gh Gh_compiler_option.cpp local_penter.obj
@@ -90,7 +94,6 @@ int main() {
9094
When run, the local `_penter` function is called on entry to `main` and `x`:
9195

9296
```Output
93-
9497
In a function!
9598
In a function!
9699
```

docs/build/reference/internal-partition.md

Lines changed: 5 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: 04/18/2022
4+
ms.date: 06/29/2022
55
author: "tylermsft"
66
ms.author: "twhitney"
77
f1_keywords: ["/internalPartition", "VC.Project.VCCLCompilerTool.Interface"]
@@ -19,13 +19,17 @@ Use the **`/internalPartition`** compiler option to treat the input file as an *
1919

2020
The following example demonstrates how to use the `/internalPartition` option:
2121

22+
Source file `m-internals.cpp`:
23+
2224
```cpp
2325
// m-internals.cpp
2426
module m:internals;
2527

2628
void internalFunc() {} // cannot have `export` since this is an internal partition
2729
```
2830

31+
Source file `m.ixx`:
32+
2933
```cpp
3034
// m.ixx
3135
export module m;

docs/build/reference/permissive-standards-conformance.md

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
---
22
title: "/permissive- (Standards conformance)"
33
description: "Reference guide to the Microsoft C++ /permissive- (Standards conformance) compiler option."
4-
ms.date: 03/15/2022
4+
ms.date: 06/29/2022
55
f1_keywords: ["/permissive", "VC.Project.VCCLCompilerTool.ConformanceMode"]
66
helpviewer_keywords: ["/permissive compiler options [C++]", "-permissive compiler options [C++]", "Standards conformance compiler options", "permissive compiler options [C++]"]
77
ms.assetid: db1cc175-6e93-4a2e-9396-c3725d2d8f71
88
---
9-
# /permissive- (Standards conformance)
9+
# `/permissive-` (Standards conformance)
1010

1111
Specify standards conformance mode to the compiler. Use this option to help you identify and fix conformance issues in your code, to make it both more correct and more portable.
1212

@@ -41,7 +41,7 @@ The MSVC compiler in earlier versions of Visual Studio 2017 doesn't support all
4141

4242
Here are some examples of code that is detected as non-conforming when you use **`/permissive-`**, along with suggested ways to fix the issues.
4343

44-
#### Use default as an identifier in native code
44+
#### Use `default` as an identifier in native code
4545

4646
```cpp
4747
void func(int default); // Error C2321: 'default' is a keyword, and
@@ -103,6 +103,8 @@ union U
103103

104104
#### Hidden friend name lookup rules
105105

106+
A declaration outside a class can make a hidden friend visible:
107+
106108
```cpp
107109
// Example 1
108110
struct S {
@@ -115,6 +117,8 @@ using type = void (*)(S *);
115117
type p = &f; // error C2065: 'f': undeclared identifier.
116118
```
117119
120+
Use of literal `nullptr` can prevent argument dependent lookup:
121+
118122
```cpp
119123
// Example 2
120124
struct S {
@@ -158,19 +162,25 @@ void func() {
158162
}
159163
```
160164

161-
#### Use of ATL Attributes
165+
#### Use of ATL attributes
166+
167+
Microsoft-specific ATL attributes can cause issues under **`/permissive-`**:
162168

163169
```cpp
164170
// Example 1
165171
[uuid("594382D9-44B0-461A-8DE3-E06A3E73C5EB")]
166172
class A {};
167173
```
168174
175+
You can fix the issue by using the **`__declspec`** form instead:
176+
169177
```cpp
170178
// Fix for example 1
171179
class __declspec(uuid("594382D9-44B0-461A-8DE3-E06A3E73C5EB")) B {};
172180
```
173181

182+
A more complex example:
183+
174184
```cpp
175185
// Example 2
176186
[emitidl];
@@ -187,6 +197,8 @@ class CFoo : public ICustom
187197
{};
188198
```
189199

200+
Resolution requires extra build steps. In this case, create an IDL file:
201+
190202
```cpp
191203
// Fix for example 2
192204
// First, create the *.idl file. The vc140.idl generated file can be
@@ -241,7 +253,7 @@ Common errors that may result from this change include:
241253
242254
- `error C2446: ':': no conversion from 'B' to 'A'`
243255
244-
A typical code pattern that can cause this issue is when some class `C` provides both a non-explicit constructor from another type `T` and a non-explicit conversion operator to type `T`. In this case, both the conversion of the second argument to the type of the third argument, and the conversion of the third argument to the type of the second argument, are valid conversions. Since both are valid, it's ambiguous according to the standard.
256+
A typical code pattern that can cause this issue is when some class `C` provides both a non-explicit constructor from another type `T` and a non-explicit conversion operator to type `T`. The conversion of the second argument to the third argument's type is a valid conversion. So is the conversion of the third argument to the second argument's type. Since both are valid, it's ambiguous according to the standard.
245257
246258
```cpp
247259
// Example 1: class that provides conversion to and initialization from some type T

0 commit comments

Comments
 (0)