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.
@@ -171,13 +170,27 @@ The function [`_configthreadlocale`](configthreadlocale.md) is used to control w
171
170
172
171
## UTF-8 Support
173
172
174
-
Starting in Windows 10 build 17134 (April 2018 Update), the Universal C Runtime supports using a UTF-8 code page. This means that `char` strings passed to C runtime functions will expect strings in the UTF-8 encoding. To enable UTF-8 mode, use "`UTF-8`" as the code page when using `setlocale`. For example, `setlocale(LC_ALL, ".utf8")` will use the current default Windows ANSI code page (ACP) for the locale and UTF-8 for the code page.
173
+
Starting in Windows 10 build 17134 (April 2018 Update), the Universal C Runtime supports using a UTF-8 code page. This means that `char` strings passed to C runtime functions will expect strings in the UTF-8 encoding. To enable UTF-8 mode, use `".UTF8"` as the code page when using `setlocale`. For example, `setlocale(LC_ALL, ".UTF8")` will use the current default Windows ANSI code page (ACP) for the locale and UTF-8 for the code page.
175
174
176
-
After calling `setlocale(LC_ALL, ".UTF8")`, you may pass "😊" to `mbtowcs` and it will be properly translated to a `wchar_t` string, whereas previously there was not a locale setting available to do this.
175
+
The string to specify UTF-8 mode is:
176
+
- case-insensitive
177
+
- the hyphen (-) is optional
178
+
- It must be in the code page part of the locale name, so must have a leading period '.' For example, `"en_US.UTF8"` or `".utf8"`
177
179
178
-
UTF-8 mode is also enabled for functions that have historically translated `char` strings using the default Windows ANSI code page (ACP). For example, calling [`_mkdir("😊")`](../reference/mkdir-wmkdir.md) while using a UTF-8 code page will correctly produce a directory with that emoji as the folder name, instead of requiring the ACP to be changed to UTF-8 prior to running your program. Likewise, calling [`_getcwd()`](../reference/getcwd-wgetcwd.md) inside of that folder will return a UTF-8 encoded string. For compatibility, the ACP is still used if the C locale code page is not set to UTF-8.
180
+
The following examples show how to specify the UTF-8 string:
179
181
180
-
The following aspects of the C Runtime that are not able to use UTF-8 because they are set during program startup and must use the default Windows ANSI code page (ACP): [`__argv`](../argc-argv-wargv.md), [`_acmdln`](../acmdln-tcmdln-wcmdln.md), and [`_pgmptr`](../pgmptr-wpgmptr.md).
182
+
`".UTF8"`\
183
+
`".UTF-8"`\
184
+
`".utf8"`\
185
+
`".utf-8"`\
186
+
`"en_us.utf8"`\
187
+
`"ja_JP.Utf-8"`
188
+
189
+
After calling `setlocale(LC_ALL, ".UTF8")`, you may pass "😊" to `mbtowcs` and it will be properly translated to a `wchar_t` string, whereas previously there wasn't a locale setting available to do this.
190
+
191
+
UTF-8 mode is also enabled for functions that have historically translated `char` strings using the default Windows ANSI code page (ACP). For example, calling [`_mkdir("😊")`](../reference/mkdir-wmkdir.md) while using a UTF-8 code page will correctly produce a directory with that emoji as the folder name, instead of requiring the ACP to be changed to UTF-8 before running your program. Likewise, calling [`_getcwd()`](../reference/getcwd-wgetcwd.md) in that folder will return a UTF-8 encoded string. For compatibility, the ACP is still used if the C locale code page is not set to UTF-8.
192
+
193
+
The following aspects of the C Runtime can't use UTF-8 because they are set during program startup and must use the default Windows ANSI code page (ACP): [`__argv`](../argc-argv-wargv.md), [`_acmdln`](../acmdln-tcmdln-wcmdln.md), and [`_pgmptr`](../pgmptr-wpgmptr.md).
181
194
182
195
Previous to this support, [`mbrtoc16`, `mbrtoc32`](../reference/mbrtoc16-mbrtoc323.md), [`c16rtomb`, and `c32rtomb`](../reference/c16rtomb-c32rtomb1.md) existed to translate between UTF-8 narrow strings, UTF-16 (same encoding as `wchar_t` on Windows platforms) and UTF-32. For compatibility reasons, these APIs still only translate to and from UTF-8 and not the code page set via `setlocale`.
183
196
@@ -190,7 +203,7 @@ To use this feature on an OS prior to Windows 10, such as Windows 7, you must us
190
203
|`setlocale`|`<locale.h>`|
191
204
|`_wsetlocale`|`<locale.h>` or `<wchar.h>`|
192
205
193
-
For additional compatibility information, see [Compatibility](../../c-runtime-library/compatibility.md).
206
+
For more compatibility information, see [Compatibility](../../c-runtime-library/compatibility.md).
Copy file name to clipboardExpand all lines: docs/error-messages/compiler-warnings/compiler-warnings-by-compiler-version.md
+20-1Lines changed: 20 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -1,7 +1,7 @@
1
1
---
2
2
title: "Compiler Warnings by compiler version"
3
3
description: "Table of Microsoft C/C++ compiler warnings by compiler version."
4
-
ms.date: 10/18/2020
4
+
ms.date: 06/07/2021
5
5
helpviewer_keywords: ["warnings, by compiler version", "cl.exe compiler, setting warning options"]
6
6
---
7
7
# Compiler Warnings by compiler version
@@ -40,13 +40,32 @@ These versions of the compiler introduced new warnings:
40
40
| Visual Studio 2019 version 16.7 | 19.27.29112.0 |
41
41
| Visual Studio 2019 version 16.8 | 19.28.29330.0 |
42
42
| Visual Studio 2019 version 16.9 | 19.28.29500.0 |
43
+
| Visual Studio 2019 version 16.10 | 19.28.30000.0 |
43
44
44
45
You can specify only the major number, the major and minor numbers, or the major, minor, and build numbers to the **`/Wv`** option. The compiler reports all warnings that match versions that begin with the specified number. It suppresses all warnings for versions greater than the specified number. For example, **`/Wv:17`** reports warnings introduced in or before any version of Visual Studio 2012, and suppresses warnings introduced by any compiler from Visual Studio 2013 (version 18) or later. To suppress warnings introduced in Visual Studio 2015 update 2 and later, you can use **`/Wv:19.00.23506`**. Use **`/Wv:19.11`** to report the warnings introduced in any version of Visual Studio before Visual Studio 2017 version 15.5, but suppress warnings introduced in Visual Studio 2017 version 15.5 and later.
45
46
46
47
The following sections list the warnings introduced by each version of Visual C++ that you can suppress by using the **`/Wv`** compiler option. The **`/Wv`** option can't suppress warnings that aren't listed, which predate the specified versions of the compiler.
47
48
48
49
::: moniker range=">= msvc-160"
49
50
51
+
## Warnings introduced in Visual Studio 2019 version 16.10 (compiler version 19.29.30000.0)
52
+
53
+
These warnings and all warnings in later versions are suppressed by using the compiler option **`/Wv:19.29`**.
54
+
55
+
| Warning | Message |
56
+
|--|--|
57
+
| C5233 |`explicit lambda capture 'identifier' is not used`|
58
+
| C5234 |`file system error: 'filename' is not a valid header-name; ignoring`|
| C5237 |`cannot resolve header unit entry 'string' to a header file in 'filename'; ignoring entry`|
62
+
| C5238 |`file system error: cannot open 'filename' for reading; ignoring`|
63
+
| C5239 |`'Symbol': potentially-throwing function called from a function declared __declspec(nothrow). Undefined behavior may occur if an exception is thrown.`|
64
+
| C5240 |`'attribute-string': attribute is ignored in this syntactic position`|
65
+
| C5241 |`'/exportHeader' usage to lookup header-name is deprecated; prefer '/headerName:arg-1 arg-2=filename'`|
66
+
| C5242 |`syntax error in pragma 'identifier'`|
67
+
| C5243 |`'Type-name': using incomplete class 'symbol' can cause potential one definition rule violation due to ABI limitation`|
68
+
50
69
## Warnings introduced in Visual Studio 2019 version 16.9 (compiler version 19.28.29700.0)
51
70
52
71
These warnings and all warnings in later versions are suppressed by using the compiler option **`/Wv:19.28.29500`**.
0 commit comments