Skip to content

Commit feb19e7

Browse files
authored
Merge pull request MicrosoftDocs#3605 from corob-msft/docs/corob/issue-3181
/external not experimental in 16.10
2 parents 27fff3f + 0c71e11 commit feb19e7

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

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

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
---
22
title: "/external (External headers diagnostics)"
33
description: "The Microsoft C++ compiler /external headers diagnostic options syntax and usage."
4-
ms.date: 05/14/2021
4+
ms.date: 06/07/2021
55
f1_keywords: ["/external", "/external:anglebrackets", "/external:env:", "/external:I", "/external:W0", "/external:W1", "/external:W2", "/external:W3", "/external:W4", "/external:templates-", "/experimental:external"]
66
helpviewer_keywords: ["/external compiler option [C++]", "-external compiler option [C++]", "external compiler option [C++]"]
77
---
88
# `/external` (External headers diagnostics)
99

1010
The **`/external`** compiler options let you specify compiler diagnostic behavior for certain header files. "External" headers are the natural complement of "Just my code": Header files such as system files or third-party library files that you can't or don't intend to change. Since you aren't going to change these files, you may decide it isn't useful to see diagnostic messages from the compiler about them. The `/external` compiler options give you control over these warnings.
1111

12-
The **`/external`** compiler options are available starting in Visual Studio 2017 version 15.6. The **`/external`** options require you also set the **`/experimental:external`** compiler option.
12+
The **`/external`** compiler options are available starting in Visual Studio 2017 version 15.6. In versions of Visual Studio before Visual Studio 2019 version 16.10, the **`/external`** options require you also set the **`/experimental:external`** compiler option.
1313

1414
## Syntax
1515

@@ -28,7 +28,7 @@ Specify diagnostics behavior:
2828
### Arguments
2929

3030
**`/experimental:external`**\
31-
Enables the external headers options, starting in Visual Studio 2017 version 15.6.
31+
Enables the external headers options. This option isn't required in Visual Studio 2019 version 16.10 and later.
3232

3333
**`/external:anglebrackets`**\
3434
Treats all headers included by `#include <header>`, where the *`header`* file is enclosed in angle brackets (**`< >`**), as external headers.
@@ -101,20 +101,20 @@ include_dir\header_file.h(6): warning C4245: 'initializing': conversion from 'in
101101
program.cpp(6): note: see reference to class template instantiation 'sample_struct<unsigned int>' being compiled
102102
```
103103

104-
To treat the header file as an external file and suppress the warning, you can use this command line instead:
104+
To treat the header file as an external file and suppress the warning, you can use this command line instead[\*](#note_experimental):
105105

106106
```cmd
107-
cl /EHsc /experimental:external /I include_dir /external:anglebrackets /external:W0 /W4 program.cpp
107+
cl /EHsc /I include_dir /external:anglebrackets /external:W0 /W4 program.cpp
108108
```
109109

110110
This command line suppresses the warning inside *`header_file.h`* while preserving warnings inside *`program.cpp`*.
111111

112112
### Warnings across the internal and external boundary
113113

114-
Setting a low warning level for external headers can hide some actionable warnings. In particular, it can turn off warnings emitted on template instantiations in user code. These warnings might indicate a problem in your code that only happens in instantiations for particular types. (For example, if you forgot to apply a type trait removing `const` or `&`.) To avoid silencing warnings inside templates defined in external headers, you can use the **`/external:templates-`** option. The compiler considers both the effective warning level in the file that defines the template, and the warning level where template instantiation occurs. Warnings emitted inside an external template appear if the template is instantiated within non-external code. For example, this command line re-enables warnings from template sources in the sample code:
114+
Setting a low warning level for external headers can hide some actionable warnings. In particular, it can turn off warnings emitted on template instantiations in user code. These warnings might indicate a problem in your code that only happens in instantiations for particular types. (For example, if you forgot to apply a type trait removing `const` or `&`.) To avoid silencing warnings inside templates defined in external headers, you can use the **`/external:templates-`** option. The compiler considers both the effective warning level in the file that defines the template, and the warning level where template instantiation occurs. Warnings emitted inside an external template appear if the template is instantiated within non-external code. For example, this command line re-enables warnings from template sources in the sample code[\*](#note_experimental):
115115

116116
```cmd
117-
cl /EHsc /experimental:external /I include_dir /external:anglebrackets /external:W0 /external:templates- /W4 program.cpp
117+
cl /EHsc /I include_dir /external:anglebrackets /external:W0 /external:templates- /W4 program.cpp
118118
```
119119

120120
The C4245 warning appears again in the output, even though the template code is inside an external header.
@@ -155,20 +155,22 @@ With this change to the library header, the author of the library ensures that t
155155

156156
### Limitations
157157

158-
Some warnings emitted by the compiler's back-end code generation aren't affected by the **`/external`** options. These warnings usually start with C47XX, though not all C47XX warnings are back-end warnings. You can still disable these warnings by using `/wd47XX`. Code analysis warnings are also unaffected, since they don't have warning levels.
158+
Some warnings emitted by the compiler's back-end code generation aren't affected by the **`/external`** options. These warnings usually start with C47XX, though not all C47XX warnings are back-end warnings. You can still disable these warnings individually by using `/wd47XX`. Code analysis warnings are also unaffected, since they don't have warning levels.
159159

160160
### To set this compiler option in the Visual Studio development environment
161161

162162
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).
163163

164164
1. Select the **Configuration Properties** > **C/C++** > **Command Line** property page.
165165

166-
1. Enter the compiler options in the **Additional Options** box.
166+
1. Enter the compiler options[\*](#note_experimental) in the **Additional Options** box.
167167

168168
### To set this compiler option programmatically
169169

170170
- See <xref:Microsoft.VisualStudio.VCProjectEngine.VCCLCompilerTool.AdditionalOptions%2A>.
171171

172+
<a name="note_experimental"></a>\* Add the `/experimental:external` option to enable the external headers options in versions of Visual Studio before Visual Studio 2019 version 16.10.
173+
172174
## See also
173175

174176
[MSVC compiler options](compiler-options.md)\

0 commit comments

Comments
 (0)