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
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.
11
11
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.
13
13
14
14
## Syntax
15
15
@@ -28,7 +28,7 @@ Specify diagnostics behavior:
28
28
### Arguments
29
29
30
30
**`/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.
32
32
33
33
**`/external:anglebrackets`**\
34
34
Treats all headers included by `#include <header>`, where the *`header`* file is enclosed in angle brackets (**`< >`**), as external headers.
This command line suppresses the warning inside *`header_file.h`* while preserving warnings inside *`program.cpp`*.
111
111
112
112
### Warnings across the internal and external boundary
113
113
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):
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
155
155
156
156
### Limitations
157
157
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.
159
159
160
160
### To set this compiler option in the Visual Studio development environment
161
161
162
162
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).
1. Enter the compiler options in the **Additional Options** box.
166
+
1. Enter the compiler options[\*](#note_experimental) in the **Additional Options** box.
167
167
168
168
### To set this compiler option programmatically
169
169
170
170
- See <xref:Microsoft.VisualStudio.VCProjectEngine.VCCLCompilerTool.AdditionalOptions%2A>.
171
171
172
+
<aname="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.
0 commit comments