Skip to content

Commit 847f5c9

Browse files
author
Colin Robertson
authored
Merge pull request MicrosoftDocs#1891 from MicrosoftDocs/master637163519268263847
Fix git push error for protected CLA branch
2 parents deb7805 + 2db4e26 commit 847f5c9

File tree

7 files changed

+41
-31
lines changed

7 files changed

+41
-31
lines changed

docs/build/reference/compiler-option-warning-level.md

Lines changed: 28 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
---
2-
title: "/w, /W0, /W1, /W2, /W3, /W4, /w1, /w2, /w3, /w4, /Wall, /wd, /we, /wo, /Wv, /WX (Warning Level)"
3-
ms.date: "01/31/2018"
2+
title: "/w, /W0, /W1, /W2, /W3, /W4, /w1, /w2, /w3, /w4, /Wall, /wd, /we, /wo, /Wv, /WX (Warning level)"
3+
description: "Reference for the Microsoft C/C++ compiler options: /w, /W0, /W1, /W2, /W3, /W4, /w1, /w2, /w3, /w4, /Wall, /wd, /we, /wo, /Wv, and /WX."
4+
ms.date: "01/31/2020"
45
f1_keywords: ["VC.Project.VCCLCompilerTool.DisableSpecificWarnings", "VC.Project.VCCLCompilerTool.WarningLevel", "VC.Project.VCCLWCECompilerTool.DisableSpecificWarnings", "VC.Project.VCCLCompilerTool.WarnAsError", "VC.Project.VCCLWCECompilerTool.WarnAsError", "/wx", "VC.Project.VCCLWCECompilerTool.WarningLevel", "/wall", "VC.Project.VCCLCompilerTool.TreatSpecificWarningsAsErrors", "/Wv", "/w0", "/w1", "/w2", "/w3", "/w4", "/wd", "/we", "/wo"]
56
helpviewer_keywords: ["/W1 compiler option [C++]", "w compiler option [C++]", "-wo compiler option [C++]", "Warning Level compiler option", "W1 compiler option [C++]", "-we compiler option [C++]", "/WX compiler option [C++]", "-wd compiler option [C++]", "WX compiler option [C++]", "wo compiler option [C++]", "Wall compiler option [C++]", "/w compiler option", "W2 compiler option [C++]", "-W2 compiler option [C++]", "wd compiler option [C++]", "/we compiler option [C++]", "we compiler option [C++]", "-W1 compiler option [C++]", "-W4 compiler option [C++]", "-Wall compiler option [C++]", "/Wall compiler option [C++]", "-W0 compiler option [C++]", "W0 compiler option [C++]", "-WX compiler option [C++]", "/wo compiler option [C++]", "W4 compiler option [C++]", "W3 compiler option [C++]", "/wd compiler option [C++]", "warnings, as errors compiler option", "/W3 compiler option [C++]", "/W0 compiler option [C++]", "/W4 compiler option [C++]", "-W3 compiler option [C++]", "-w compiler option [C++]", "/W2 compiler option [C++]", "/Wv compiler option [C++]"]
67
---
7-
# /w, /W0, /W1, /W2, /W3, /W4, /w1, /w2, /w3, /w4, /Wall, /wd, /we, /wo, /Wv, /WX (Warning Level)
8+
# /w, /W0, /W1, /W2, /W3, /W4, /w1, /w2, /w3, /w4, /Wall, /wd, /we, /wo, /Wv, /WX (Warning level)
89

910
Specifies how the compiler generates warnings for a given compilation.
1011

@@ -31,23 +32,28 @@ Specifies how the compiler generates warnings for a given compilation.
3132

3233
The warning options specify which compiler warnings to display and the warning behavior for the entire compilation.
3334

34-
The warning options and related arguments are described in the following table:
35+
The warning options and related arguments are described in the following tables:
3536

36-
|Option|Description|
37-
------------|-----------------|
38-
|**/w**|Suppresses all compiler warnings.|
39-
|**/W0**<br /><br /> **/W1**<br /><br /> **/W2**<br /><br /> **/W3**<br /><br /> **/W4**|Specifies the level of warnings to be generated by the compiler. Valid warning levels range from 0 to 4:<br />**/W0** suppresses all warnings. This is equivalent to **/w**.<br />**/W1** displays level 1 (severe) warnings. **/W1** is the default setting in the command line compiler.<br />**/W2** displays level 1 and level 2 (significant) warnings.<br />**/W3** displays level 1, level 2 and level 3 (production quality) warnings. **/W3** is the default setting in the IDE.<br />**/W4** displays level 1, level 2, and level 3 warnings, and all level 4 (informational) warnings that are not turned off by default. We recommend that you use this option to provide lint-like warnings. For a new project, it may be best to use **/W4** in all compilations; this will ensure the fewest possible hard-to-find code defects.|
40-
|**/Wall**|Displays all warnings displayed by **/W4** and all other warnings that **/W4** does not include—for example, warnings that are off by default. For more information, see [Compiler Warnings That Are Off By Default](../../preprocessor/compiler-warnings-that-are-off-by-default.md).|
41-
|**/Wv**\[**:**_version_]|Displays only warnings introduced in compiler version *version* and earlier. You can use this option to suppress new warnings in code when you migrate to a newer version of the compiler, and to maintain your existing build process while you fix them. The optional parameter *version* takes the form *nn*[.*mm*[.*bbbbb*]] where *nn* is the major version number, *mm* is the optional minor version number, and *bbbbb* is the optional build number of the compiler. For example, use */Wv:17* to display warnings introduced in Visual Studio 2012 (that is, any version of the compiler that has a major version number of 17) or earlier, but suppress warnings introduced in Visual Studio 2013 (major version 18) and later. By default, **/Wv** uses the current compiler version number, and no warnings are suppressed. For information about which warnings are suppressed by compiler version, see [Compiler Warnings by compiler version](../../error-messages/compiler-warnings/compiler-warnings-by-compiler-version.md).|
42-
|**/WX**|Treats all compiler warnings as errors. For a new project, it may be best to use **/WX** in all compilations; resolving all warnings ensures the fewest possible hard-to-find code defects.<br /><br /> The linker also has a **/WX** option. For more information, see [/WX (Treat Linker Warnings as Errors)](wx-treat-linker-warnings-as-errors.md).|
43-
|**/w1**_nnnn_<br /><br /> **/w2**_nnnn_<br /><br /> **/w3**_nnnn_<br /><br /> **/w4**_nnnn_|Sets the warning level for the warning number specified by _nnnn_. This lets you change the compiler behavior for that warning when a specific warning level is set. You can use these options in combination with other warning options to enforce your own coding standards for warnings, rather than the default ones provided by Visual Studio.<br /><br /> For example, **/w34326** causes C4326 to be generated as a level 3 warning instead of level 1. If you compile by using both the **/w34326** option and the **/W2** option, warning C4326 is not generated.|
44-
|**/wd**_nnnn_|Suppresses the compiler warning that is specified by _nnnn_.<br /><br /> For example, **/wd4326** suppresses compiler warning C4326.|
45-
|**/we**_nnnn_|Treats the compiler warning that is specified by _nnnn_ as an error.<br /><br /> For example, **/we4326** causes warning number C4326 to be treated as an error by the compiler.|
46-
|**/wo**_nnnn_|Reports the compiler warning that is specified by _nnnn_ only once.<br /><br /> For example, **/wo4326** causes warning C4326 to be reported only once, the first time it is encountered by the compiler.|
37+
Option | Description
38+
------ | -----------
39+
**/w** | Suppresses all compiler warnings.
40+
**/W0**<br /><br /> **/W1**<br /><br /> **/W2**<br /><br /> **/W3**<br /><br /> **/W4** | Specifies the level of warnings to be generated by the compiler. Valid warning levels range from 0 to 4:<br />**/W0** suppresses all warnings. It's equivalent to **/w**.<br />**/W1** displays level 1 (severe) warnings. **/W1** is the default setting in the command-line compiler.<br />**/W2** displays level 1 and level 2 (significant) warnings.<br />**/W3** displays level 1, level 2, and level 3 (production quality) warnings. **/W3** is the default setting in the IDE.<br />**/W4** displays level 1, level 2, and level 3 warnings, and all level 4 (informational) warnings that aren't off by default. We recommend that you use this option to provide lint-like warnings. For a new project, it may be best to use **/W4** in all compilations. This option helps ensure the fewest possible hard-to-find code defects.
41+
**/Wall** | Displays all warnings displayed by **/W4** and all other warnings that **/W4** doesn't include—for example, warnings that are off by default. For more information, see [Compiler warnings that are off by default](../../preprocessor/compiler-warnings-that-are-off-by-default.md).
42+
**/Wv**\[**:**_version_] | Displays only warnings introduced in the *version* compiler version and earlier. You can use this option to suppress new warnings in code when you migrate to a newer version of the compiler. It lets you maintain your existing build process while you fix them. The optional parameter *version* takes the form *nn*\[.*mm*\[.*bbbbb*]], where *nn* is the major version number, *mm* is the optional minor version number, and *bbbbb* is the optional build number of the compiler. For example, use **/Wv:17** to display only warnings introduced in Visual Studio 2012 (major version 17) or earlier. That is, it displays warnings from any version of the compiler that has a major version number of 17 or less. It suppresses warnings introduced in Visual Studio 2013 (major version 18) and later. By default, **/Wv** uses the current compiler version number, and no warnings are suppressed. For information about which warnings are suppressed by compiler version, see [Compiler warnings by compiler version](../../error-messages/compiler-warnings/compiler-warnings-by-compiler-version.md).
43+
**/WX** | Treats all compiler warnings as errors. For a new project, it may be best to use **/WX** in all compilations; resolving all warnings ensures the fewest possible hard-to-find code defects.<br /><br /> The linker also has a **/WX** option. For more information, see [/WX (Treat linker warnings as errors)](wx-treat-linker-warnings-as-errors.md).
4744

48-
If you use any of the warning options when you create a precompiled header by using the [/Yc](yc-create-precompiled-header-file.md) option, any use of the precompiled header by using the [/Yu](yu-use-precompiled-header-file.md) option causes those same warning options to be in effect again. You can override the warning options set in the precompiled header by using another warning option on the command line.
45+
The following options are mutually exclusive with each other. The last option that's specified from this group is the one applied:
4946

50-
You can use a [#pragma warning](../../preprocessor/warning.md) directive to control the level of warning that is reported at compile time in specific source files.
47+
Option | Description
48+
------ | -----------
49+
**/w1**_nnnn_<br /><br /> **/w2**_nnnn_<br /><br /> **/w3**_nnnn_<br /><br /> **/w4**_nnnn_ | Sets the warning level for the warning number specified by _nnnn_. These options let you change the compiler behavior for that warning when a specific warning level is set. You can use these options in combination with other warning options to enforce your own coding standards for warnings, rather than the default ones provided by Visual Studio.<br /><br /> For example, **/w34326** causes C4326 to be generated as a level 3 warning instead of level 1. If you compile by using both the **/w34326** option and the **/W2** option, warning C4326 isn't generated.
50+
**/wd**_nnnn_ | Suppresses the compiler warning that is specified by _nnnn_.<br /><br /> For example, **/wd4326** suppresses compiler warning C4326.
51+
**/we**_nnnn_ | Treats the compiler warning that is specified by _nnnn_ as an error.<br /><br /> For example, **/we4326** causes warning number C4326 to be treated as an error by the compiler.
52+
**/wo**_nnnn_ | Reports the compiler warning that is specified by _nnnn_ only once.<br /><br /> For example, **/wo4326** causes warning C4326 to be reported only once, the first time it's encountered by the compiler.
53+
54+
If you use any warning options when you create a precompiled header, it keeps those settings. Using the precompiled header puts those same warning options in effect again. To override the precompiled header warning options, set another warning option on the command line.
55+
56+
You can use a [#pragma warning](../../preprocessor/warning.md) directive to control the level of warning that's reported at compile time in specific source files.
5157

5258
Warning pragma directives in source code are unaffected by the **/w** option.
5359

@@ -57,7 +63,7 @@ The [build errors documentation](../../error-messages/compiler-errors-1/c-cpp-bu
5763

5864
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).
5965

60-
1. To set the **/W0**, **/W1**, **/W2**, **/W3**, **/W4**, **/Wall**, **/Wv**, **/WX** or **/WX-** options, select the **Configuration Properties** > **C/C++** > **General** property page.
66+
1. To set the **/W0**, **/W1**, **/W2**, **/W3**, **/W4**, **/Wall**, **/Wv**, **/WX**, or **/WX-** options, select **Configuration Properties** > **C/C++** > **General**.
6167

6268
- To set the **/W0**, **/W1**, **/W2**, **/W3**, **/W4**, or **/Wall** options, modify the **Warning Level** property.
6369

@@ -67,9 +73,9 @@ The [build errors documentation](../../error-messages/compiler-errors-1/c-cpp-bu
6773

6874
1. To set the **/wd** or **/we** options, select the **Configuration Properties** > **C/C++** > **Advanced** property page.
6975

70-
- To set the **/wd** option, select the **Disable Specific Warnings** property drop down control and then choose **Edit**. In the edit box in the **Disable Specific Warnings** dialog, enter the warning number. To enter more than one warning, separate the values by using a semicolon (**;**). For example, to disable both C4001 and C4010, enter **4001;4010**. Choose **OK** to save your changes and return to the **Property Pages** dialog.
76+
- To set the **/wd** option, select the **Disable Specific Warnings** property dropdown control and then choose **Edit**. In the edit box in the **Disable Specific Warnings** dialog, enter the warning number. To enter more than one warning, separate the values by using a semicolon (**;**). For example, to disable both C4001 and C4010, enter **4001;4010**. Choose **OK** to save your changes and return to the **Property Pages** dialog.
7177

72-
- To set the **/we** option, Select the **Treat Specific Warnings As Errors** property drop down control and then choose **Edit**. In the edit box in the **Treat Specific Warnings As Errors** dialog, enter the warning number. To enter more than one warning, separate the values by using a semicolon (**;**). For example, to treat both C4001 and C4010 as errors, enter **4001;4010**. Choose **OK** to save your changes and return to the **Property Pages** dialog.
78+
- To set the **/we** option, Select the **Treat Specific Warnings As Errors** property dropdown control and then choose **Edit**. In the edit box in the **Treat Specific Warnings As Errors** dialog, enter the warning number. To enter more than one warning, separate the values by using a semicolon (**;**). For example, to treat both C4001 and C4010 as errors, enter **4001;4010**. Choose **OK** to save your changes and return to the **Property Pages** dialog.
7379

7480
1. To set the **/wo** option, select the **Configuration Properties** > **C/C++** > **Command Line** property page. Enter the compiler option in the **Additional Options** box.
7581

@@ -81,5 +87,5 @@ The [build errors documentation](../../error-messages/compiler-errors-1/c-cpp-bu
8187

8288
## See also
8389

84-
[MSVC Compiler Options](compiler-options.md)\
85-
[MSVC Compiler Command-Line Syntax](compiler-command-line-syntax.md)
90+
[MSVC compiler options](compiler-options.md)\
91+
[MSVC compiler command-line syntax](compiler-command-line-syntax.md)

docs/c-runtime-library/reference/fegetexceptflag2.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ The **fegetexceptflag** function stores the current state of the floating-point
4545
|FE_INVALID|A domain error occurred in an earlier floating-point operation.|
4646
|FE_OVERFLOW|A range error occurred; an earlier floating-point operation result was too large to be represented.|
4747
|FE_UNDERFLOW|An earlier floating-point operation result was too small to be represented at full precision; a denormal value was created.|
48-
|FE_ALLEXCEPT|The bitwise OR of all supported floating-point exceptions.|
48+
|FE_ALL_EXCEPT|The bitwise OR of all supported floating-point exceptions.|
4949

5050
The *excepts* argument may be zero, one of the supported floating-point exception macros, or the bitwise OR of two or more of the macros. The effect of any other argument value is undefined.
5151

docs/c-runtime-library/reference/feraiseexcept.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ The **feraiseexcept** function attempts to raise the floating-point exceptions s
4040
|FE_INVALID|A domain error occurred in an earlier floating-point operation.|
4141
|FE_OVERFLOW|A range error occurred; an earlier floating-point operation result was too large to be represented.|
4242
|FE_UNDERFLOW|An earlier floating-point operation result was too small to be represented at full precision; a denormal value was created.|
43-
|FE_ALLEXCEPT|The bitwise OR of all supported floating-point exceptions.|
43+
|FE_ALL_EXCEPT|The bitwise OR of all supported floating-point exceptions.|
4444

4545
The *excepts* argument may be zero, one of the exception macro values, or the bitwise OR of two or more of the supported exception macros. If one of the specified exception macros is FE_OVERFLOW or FE_UNDERFLOW, the FE_INEXACT exception may be raised as a side-effect.
4646

docs/c-runtime-library/reference/fesetexceptflag2.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ The **fesetexceptflag** function sets the state of the floating-point exception
4545
|FE_INVALID|A domain error occurred in an earlier floating-point operation.|
4646
|FE_OVERFLOW|A range error occurred; an earlier floating-point operation result was too large to be represented.|
4747
|FE_UNDERFLOW|An earlier floating-point operation result was too small to be represented at full precision; a denormal value was created.|
48-
|FE_ALLEXCEPT|The bitwise OR of all supported floating-point exceptions.|
48+
|FE_ALL_EXCEPT|The bitwise OR of all supported floating-point exceptions.|
4949

5050
The *excepts* argument may be zero, one of the supported floating-point exception macros, or the bitwise OR of two or more of the macros. The effect of any other argument value is undefined.
5151

docs/c-runtime-library/reference/fetestexcept1.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ Use the fetestexcept function to determine which exceptions were raised by a flo
4141
|FE_INVALID|A domain error occurred in an earlier floating-point operation.|
4242
|FE_OVERFLOW|A range error occurred; an earlier floating-point operation result was too large to be represented.|
4343
|FE_UNDERFLOW|An earlier floating-point operation result was too small to be represented at full precision; a denormal value was created.|
44-
|FE_ALLEXCEPT|The bitwise OR of all supported floating-point exceptions.|
44+
|FE_ALL_EXCEPT|The bitwise OR of all supported floating-point exceptions.|
4545

4646
The specified *excepts* argument may be 0, one of the supported floating-point exception macros, or the bitwise OR of two or more of the macros. The effect of any other *excepts* argument value is undefined.
4747

docs/cpp/dynamic-cast-operator.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
---
22
title: "dynamic_cast Operator"
3-
ms.date: "11/19/2018"
3+
description: "Overview of the C++ language dynamic_cast operator."
4+
ms.date: "02/03/2020"
45
f1_keywords: ["dynamic_cast_cpp"]
56
helpviewer_keywords: ["dynamic_cast keyword [C++]"]
67
ms.assetid: f380ada8-6a18-4547-93c9-63407f19856b
@@ -122,11 +123,13 @@ A pointer to an object of type `D` can be safely cast to `B` or `C`. However, if
122123
// dynamic_cast_4.cpp
123124
// compile with: /c /GR
124125
class A {virtual void f();};
125-
class B {virtual void f();};
126-
class D : public B {virtual void f();};
126+
class B : public A {virtual void f();};
127+
class C : public A {virtual void f();};
128+
class D : public B, public C {virtual void f();};
127129

128130
void f() {
129131
D* pd = new D;
132+
A* pa = dynamic_cast<A*>(pd); // C4540, ambiguous cast fails at runtime
130133
B* pb = dynamic_cast<B*>(pd); // first cast to B
131134
A* pa2 = dynamic_cast<A*>(pb); // ok: unambiguous
132135
}

0 commit comments

Comments
 (0)