Skip to content

Commit 5e3d947

Browse files
committed
17.4 Release updates
1 parent 0778480 commit 5e3d947

9 files changed

Lines changed: 360 additions & 29 deletions

docs/build/reference/compiler-options-listed-alphabetically.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: "Compiler options listed alphabetically"
33
description: "Reference listing in alphabetical order of the Microsoft C/C++ compiler command-line options."
4-
ms.date: 04/15/2022
4+
ms.date: 11/07/2022
55
helpviewer_keywords: ["compiler options, C++"]
66
---
77
# Compiler options listed alphabetically
@@ -212,9 +212,11 @@ This table contains an alphabetical list of compiler options. For a list of comp
212212
| [`/Z7`](z7-zi-zi-debug-information-format.md) | Generates C 7.0-compatible debugging information. |
213213
| [`/Za`](za-ze-disable-language-extensions.md) | Disables some C89 language extensions in C code. |
214214
| [`/Zc:__cplusplus[-]`](zc-cplusplus.md) | Enable the `__cplusplus` macro to report the supported standard (off by default). |
215+
| [`/Zc:__STDC__`](zc-stdc.md) | Enable the `__STDC__` macro to report the C standard is supported (off by default). |
215216
| [`/Zc:alignedNew[-]`](zc-alignednew.md) | Enable C++17 over-aligned dynamic allocation (on by default in C++17). |
216217
| [`/Zc:auto[-]`](zc-auto-deduce-variable-type.md) | Enforce the new Standard C++ meaning for **`auto`** (on by default). |
217218
| [`/Zc:char8_t[-]`](zc-char8-t.md) | Enable or disable C++20 native `u8` literal support as `const char8_t` (off by default, except under **`/std:c++20`**). |
219+
| [`/Zc:enumTypes[-]`](zc-enumtypes.md) | Enable Standard C++ rules for inferred `enum` base types (Off b y default, not implied by **`/permissive-`**). |
218220
| [`/Zc:externC[-]`](zc-externc.md) | Enforce Standard C++ rules for `extern "C"` functions (implied by **`/permissive-`**). |
219221
| [`/Zc:externConstexpr[-]`](zc-externconstexpr.md) | Enable external linkage for **`constexpr`** variables (off by default). |
220222
| [`/Zc:forScope[-]`](zc-forscope-force-conformance-in-for-loop-scope.md) | Enforce Standard C++ **`for`** scoping rules (on by default). |

docs/build/reference/compiler-options-listed-by-category.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: "Compiler Options Listed by Category"
33
description: "Reference listing by category of the Microsoft C/C++ compiler command-line options."
4-
ms.date: 04/15/2022
4+
ms.date: 11/07/2022
55
helpviewer_keywords: ["compiler options, C++"]
66
ms.assetid: c4750dcf-dba0-4229-99b6-45cdecc11729
77
---
@@ -173,10 +173,12 @@ This article contains a categorical list of compiler options. For an alphabetica
173173
| [`/vmv`](vmm-vms-vmv-general-purpose-representation.md) | Declares virtual inheritance. |
174174
| [`/Z7`](z7-zi-zi-debug-information-format.md) | Generates C 7.0-compatible debugging information. |
175175
| [`/Za`](za-ze-disable-language-extensions.md) | Disables some C89 language extensions in C code. |
176+
| [`/Zc:__cplusplus[-]`](zc-cplusplus.md) | Enable the `__cplusplus` macro to report the supported standard (off by default). |
177+
| [`/Zc:__STDC__`](zc-stdc.md) | Enable the `__STDC__` macro to report the C standard is supported (off by default). |
176178
| [`/Zc:alignedNew[-]`](zc-alignednew.md) | Enable C++17 over-aligned dynamic allocation (on by default in C++17). |
177179
| [`/Zc:auto[-]`](zc-auto-deduce-variable-type.md) | Enforce the new Standard C++ meaning for **`auto`** (on by default). |
178180
| [`/Zc:char8_t[-]`](zc-char8-t.md) | Enable or disable C++20 native `u8` literal support as `const char8_t` (off by default, except under **`/std:c++20`**). |
179-
| [`/Zc:__cplusplus[-]`](zc-cplusplus.md) | Enable the `__cplusplus` macro to report the supported standard (off by default). |
181+
| [`/Zc:enumTypes[-]`](zc-enumtypes.md) | Enable Standard C++ rules for inferred `enum` base types (Off b y default, not implied by **`/permissive-`**). |
180182
| [`/Zc:externC[-]`](zc-externc.md) | Enforce Standard C++ rules for `extern "C"` functions (implied by **`/permissive-`**). |
181183
| [`/Zc:externConstexpr[-]`](zc-externconstexpr.md) | Enable external linkage for **`constexpr`** variables (off by default). |
182184
| [`/Zc:forScope[-]`](zc-forscope-force-conformance-in-for-loop-scope.md) | Enforce Standard C++ **`for`** scoping rules (on by default). |
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
---
2+
description: "Learn more about the /Zc:enumTypes (Enable enum type deduction) compiler option."
3+
title: "/Zc:enumTypes (Enable C++20 enumTypes type)"
4+
ms.date: 11/07/2022
5+
f1_keywords: ["/Zc:enumTypes"]
6+
helpviewer_keywords: ["-Zc:enumTypes compiler option (C++)", "/Zc:enumTypes compiler option (C++)"]
7+
---
8+
# `/Zc:enumTypes` (Enable enum type deduction)
9+
10+
The **`/Zc:enumTypes`** compiler option enables C++ conforming **`enum`** underlying type and enumerator type deduction.
11+
12+
## Syntax
13+
14+
> **`/Zc:enumTypes`**\[**`-`**]
15+
16+
## Remarks
17+
18+
The **`/Zc:enumTypes`** compiler option implements Standard C++ conforming behavior for deduction of enumeration base types and the types of enumerators.
19+
20+
The **`/Zc:enumTypes`** option is new in Visual Studio 2022 version 17.4. This option is off by default, and isn't enabled by **`/permissive-`**. To explicitly disable the option, use **`/Zc:enumTypes-`**.
21+
22+
When enabled, the **`/Zc:enumTypes`** option is a potential source and binary breaking change. Some enumeration types change size when the conforming **`/Zc:enumTypes`** option is enabled. Certain Windows SDK headers include such enumeration definitions.
23+
24+
The C++ Standard requires that the underlying type of an enumeration is large enough to hold all enumerators declared in it. Sufficiently large enumerators can set the underlying type of the **`enum`** to **`unsigned int`**, **`long long`**, or **`unsigned long long`**. Previously, such enumeration types always had an underlying type of **`int`** in the Microsoft compiler, regardless of enumerator values.
25+
26+
The C++ Standard also specifies that, within an enumeration definition that has no fixed underlying type, the types of enumerators are determined by their initializers. Or, for the enumerators with no initializer, by the type of the previous enumerator (accounting for overflow). Previously, such enumerators were always given the deduced type of the enumeration, with a placeholder for the underlying type (typically **`int`**).
27+
28+
In versions of Visual Studio before Visual Studio 2022 version 17.4, the C++ compiler didn't correctly determine the underlying type of an unscoped enumeration with no fixed base type. The compiler also didn't correctly model the types of enumerators. It could assume an incorrect type in enumerations without a fixed underlying type before the closing brace of the enumeration. Under **`/Zc:enumTypes`**, the compiler correctly implements the standard behavior.
29+
30+
### Example: Underlying type of unscoped `enum` with no fixed type
31+
32+
```cpp
33+
enum Unsigned
34+
{
35+
A = 0xFFFFFFFF // Value 'A' does not fit in 'int'.
36+
};
37+
38+
// Previously, this static_assert failed. It passes with /Zc:enumTypes.
39+
static_assert(std::is_same_v<std::underlying_type_t<Unsigned>, unsigned int>);
40+
41+
template <typename T>
42+
void f(T x)
43+
{
44+
}
45+
46+
int main()
47+
{
48+
// Previously called f<int>, now calls f<unsigned int>.
49+
f(+A);
50+
}
51+
52+
// Previously, this enum would have an underlying type of `int`,
53+
// but Standard C++ requires this to have a 64-bit underlying type.
54+
// The /Zc:enumTypes option changes the size of this enum from 4 to 8,
55+
// which could impact binary compatibility with code compiled with an
56+
// earlier compiler version, or without the switch.
57+
enum Changed
58+
{
59+
X = -1,
60+
Y = 0xFFFFFFFF
61+
};
62+
```
63+
64+
### Example: Enumerators within an `enum` definition with no fixed underlying type
65+
66+
```cpp
67+
enum Enum {
68+
A = 'A',
69+
B = sizeof(A)
70+
};
71+
72+
static_assert(B == 1); // previously failed, now succeeds under /Zc:enumTypes
73+
```
74+
75+
In this example the enumerator `A` should have type **`char`** prior to the closing brace of the enumeration, so `B` should be initialized using `sizeof(char)`. Before the **`/Zc:enumTypes`** fix, `A` had enumeration type `Enum` with a deduced underlying type **`int`**, and `B` was initialized using `sizeof(Enum)`, or 4.
76+
77+
### To set this compiler option in Visual Studio
78+
79+
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).
80+
81+
1. Select the **Configuration Properties** > **C/C++** > **Command Line** property page.
82+
83+
1. In **Additional options**, add **`/Zc:enumTypes`** or **`/Zc:enumTypes-`**. Choose **OK** or **Apply** to save your changes.
84+
85+
## See also
86+
87+
[`/Zc` (Conformance)](zc-conformance.md)\
88+
[`/std` (Specify language standard version)](std-specify-language-standard-version.md)

docs/build/reference/zc-stdc.md

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
---
2+
description: "Learn more about the /Zc:__STDC__ (Enable enum type deduction) compiler option."
3+
title: "/Zc:__STDC__ (Enable C++20 __STDC__ type)"
4+
ms.date: 11/07/2022
5+
f1_keywords: ["/Zc:__STDC__"]
6+
helpviewer_keywords: ["-Zc:__STDC__ compiler option (C++)", "/Zc:__STDC__ compiler option (C++)"]
7+
---
8+
# `/Zc:__STDC__` (Define `__STDC__` in C)
9+
10+
The **`/Zc:__STDC__`** compiler option defines the built-in `__STDC__` preprocessor macro as 1 in C code.
11+
12+
## Syntax
13+
14+
> **`/Zc:__STDC__`**
15+
16+
## Remarks
17+
18+
The **`/Zc:__STDC__`** compiler option implements Standard C conforming behavior for the `__STDC__` preprocessor macro, setting it to 1 when compiling C11 and C17 code.
19+
20+
The **`/Zc:__STDC__`** option is new in Visual Studio 2022 version 17.2. This option is off by default, but can be enabled explicitly when **`/std:c11`** or **`/std:c17`** is specified. There's no negative version of the option.
21+
22+
This option is a source breaking change. Due to the behavior of the UCRT, which doesn't expose POSIX functions when `__STDC__` is `1`, it isn't possible to define this macro for C by default without introducing breaking changes to the stable language versions.
23+
24+
### Example
25+
26+
```c
27+
// test__STDC__.c
28+
#include <io.h>
29+
#include <fcntl.h>
30+
#include <stdio.h>
31+
32+
int main() {
33+
#if __STDC__
34+
int f = _open("file.txt", _O_RDONLY);
35+
_close(f);
36+
#else
37+
int f = open("file.txt", O_RDONLY);
38+
close(f);
39+
#endif
40+
}
41+
42+
/* Command line behavior
43+
44+
C:\Temp>cl /EHsc /W4 /Zc:__STDC__ test__STDC__.c && test__STDC__
45+
46+
*/
47+
```
48+
49+
### To set this compiler option in Visual Studio
50+
51+
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).
52+
53+
1. Select the **Configuration Properties** > **C/C++** > **Command Line** property page.
54+
55+
1. In **Additional options**, add *`/Zc:__STDC__`*. Choose **OK** or **Apply** to save your changes.
56+
57+
## See also
58+
59+
[`/Zc` (Conformance)](zc-conformance.md)\
60+
[`/std` (Specify language standard version)](std-specify-language-standard-version.md)

docs/error-messages/compiler-warnings/compiler-warnings-by-compiler-version.md

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: "Compiler Warnings by compiler version"
33
description: "Table of Microsoft C/C++ compiler warnings by compiler version."
4-
ms.date: 08/08/2022
4+
ms.date: 11/07/2022
55
helpviewer_keywords: ["warnings, by compiler version", "cl.exe compiler, setting warning options"]
66
---
77
# Compiler Warnings by compiler version
@@ -46,13 +46,26 @@ These versions of the compiler introduced new warnings:
4646
| Visual Studio 2022 version 17.1 | 19.31 |
4747
| Visual Studio 2022 version 17.2 | 19.32 |
4848
| Visual Studio 2022 version 17.3 | 19.33 |
49+
| Visual Studio 2022 version 17.4 | 19.34 |
4950

5051
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.
5152

5253
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.
5354

5455
::: moniker range=">= msvc-170"
5556

57+
## Warnings introduced in Visual Studio 2022 version 17.4 (compiler version 19.34)
58+
59+
These warnings and all warnings in later versions are suppressed by using the compiler option **`/Wv:19.33`**.
60+
61+
| Warning | Message |
62+
|--|--|
63+
| C5260 | the constant variable '*variable-name*' has internal linkage in an included header file context, but external linkage in imported header unit context; consider declaring it '`inline`' as well if it will be shared across translation units, or '`static`' to express intent to use it local to this translation unit |
64+
| C5261 | no integer type can represent all enumerator values in enumeration '*enum-name*' |
65+
| C5262 | implicit fall-through occurs here; are you missing a `break` statement? Use `[[fallthrough]]` when a `break` statement is intentionally omitted between cases |
66+
| C5263 | calling '`std::move`' on a temporary object prevents copy elision |
67+
| C5264 | '*variable-name*': '`const`' variable is not used |
68+
5669
## Warnings introduced in Visual Studio 2022 version 17.3 (compiler version 19.33)
5770

5871
These warnings and all warnings in later versions are suppressed by using the compiler option **`/Wv:19.32`**.

docs/error-messages/compiler-warnings/compiler-warnings-c4800-through-c4999.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: "Compiler warnings C4800 Through C5999"
33
description: "Table of Microsoft C/C++ compiler warnings C4800 through C5999."
4-
ms.date: 08/08/2022
4+
ms.date: 11/07/2022
55
f1_keywords: ["C4808", "C4809", "C4825", "C4827", "C4837", "C4842", "C4844", "C4845", "C4846", "C4847", "C4848", "C4854", "C4855", "C4856", "C4857", "C4872", "C4880", "C4881", "C4882", "C4916", "C4921", "C4934", "C4954", "C4955", "C4963", "C4966", "C4970", "C4971", "C4973", "C4974", "C4981", "C4983", "C4987", "C4988", "C4989", "C4990", "C4991", "C4992", "C4998", "C5022", "C5023", "C5024", "C5025", "C5026", "C5027", "C5028", "C5029", "C5030", "C5031", "C5032", "C5034", "C5035", "C5036", "C5039", "C5040", "C5041", "C5042", "C5043", "C5044", "C5047", "C5048", "C5049", "C5051", "C5052", "C5053", "C5057", "C5058", "C5059", "C5060", "C5061", "C5062", "C5063", "C5081", "C5100", "C5101", "C5102", "C5103", "C5104", "C5106", "C5107", "C5108", "C5200", "C5201", "C5202", "C5203", "C5204", "C5205", "C5206", "C5207", "C5209", "C5210", "C5211", "C5212", "C5213", "C5214", "C5215", "C5216", "C5217", "C5218", "C5219", "C5220", "C5221", "C5222", "C5223", "C5224", "C5225", "C5226", "C5227", "C5228", "C5229", "C5230", "C5231", "C5232", "C5233", "C5234", "C5235", "C5236", "C5237", "C5238", "C5239", "C5241", "C5242", "C5244", "C5245", "C5246", "C5249", "C5250", "C5251", "C5252", "C5253", "C5254", "C5255", "C5256", "C5257", "C5258", "C5300", "C5301", "C5302"]
66
helpviewer_keywords: ["C4808", "C4809", "C4825", "C4827", "C4837", "C4842", "C4844", "C4845", "C4846", "C4847", "C4848", "C4854", "C4855", "C4856", "C4857", "C4872", "C4880", "C4881", "C4882", "C4916", "C4921", "C4934", "C4954", "C4955", "C4963", "C4966", "C4970", "C4971", "C4973", "C4974", "C4981", "C4983", "C4987", "C4988", "C4989", "C4990", "C4991", "C4992", "C4998", "C5022", "C5023", "C5024", "C5025", "C5026", "C5027", "C5028", "C5029", "C5030", "C5031", "C5032", "C5034", "C5035", "C5036", "C5039", "C5040", "C5041", "C5042", "C5043", "C5044", "C5047", "C5048", "C5049", "C5051", "C5052", "C5053", "C5057", "C5058", "C5059", "C5060", "C5061", "C5062", "C5063", "C5081", "C5100", "C5101", "C5102", "C5103", "C5104", "C5106", "C5107", "C5108", "C5200", "C5201", "C5202", "C5203", "C5204", "C5205", "C5206", "C5207", "C5209", "C5210", "C5211", "C5212", "C5213", "C5214", "C5215", "C5216", "C5217", "C5218", "C5219", "C5220", "C5221", "C5222", "C5223", "C5224", "C5225", "C5226", "C5227", "C5228", "C5229", "C5230", "C5231", "C5232", "C5233", "C5234", "C5235", "C5236", "C5237", "C5238", "C5239", "C5241", "C5242", "C5244", "C5245", "C5246", "C5249", "C5250", "C5251", "C5252", "C5253", "C5254", "C5255", "C5256", "C5257", "C5258", "C5300", "C5301", "C5302"]
77
---
@@ -57,7 +57,7 @@ The articles in this section of the documentation explain a subset of the warnin
5757
| Compiler warning (level 1) C4857 | C++/CLI mode does not support C++ versions newer than C++17; setting language to `/std:c++17` |
5858
| [Compiler warning (level 4) C4866](c4866.md) | compiler may not enforce left-to-right evaluation order for call to *operator_name* |
5959
| [Compiler warning (level 1, error) C4867](compiler-warning-c4867.md) | '*function*': function call missing argument list; use '*call*' to create a pointer to member |
60-
| [Compiler warning (level 4) C4868](compiler-warning-c4868.md) | '_file_(*line_number*)' compiler may not enforce left-to-right evaluation order in braced initialization list |
60+
| [Compiler warning (level 4) C4868](compiler-warning-c4868.md) | '*file*(*line_number*)' compiler may not enforce left-to-right evaluation order in braced initialization list |
6161
| Compiler warning (level 2) C4872 | floating point division by zero detected when compiling the call graph for the `concurrency::parallel_for_each` at: '*location*' |
6262
| Compiler warning (level 1) C4880 | casting from 'const *type_1*' to '*type_2*': casting away constness from a pointer or reference may result in undefined behavior in an amp restricted function |
6363
| Compiler warning (level 4) C4881 | the constructor and/or the destructor will not be invoked for `tile_static` variable '*variable-name*' |
@@ -241,6 +241,12 @@ The articles in this section of the documentation explain a subset of the warnin
241241
| Compiler warning (level 1, off) C5256 | '*enumeration*': a non-defining declaration of an enumeration with a fixed underlying type is only permitted as a standalone declaration |
242242
| Compiler warning (level 1 or 4) C5257 | '*enumeration*': enumeration was previously declared without a fixed underlying type |
243243
| Compiler warning (level 4, off) C5258 | explicit capture of '*symbol*' is not required for this use |
244+
| Compiler warning (level 4, off) C5259 | '*specialized-type*': explicit specialization requires 'template <>' |
245+
| Compiler warning (level 1) C5260 | the constant variable '*variable-name*' has internal linkage in an included header file context, but external linkage in imported header unit context; consider declaring it 'inline' as well if it will be shared across translation units, or 'static' to express intent to use it local to this translation unit |
246+
| Compiler warning (level 2) C5261 | no integer type can represent all enumerator values in enumeration '*enum-name*' |
247+
| Compiler warning (level 1, off) C5262 | implicit fall-through occurs here; are you missing a break statement? Use `[[fallthrough]]` when a `break` statement is intentionally omitted between cases |
248+
| Compiler warning (level 4, off) C5263 | calling '`std::move`' on a temporary object prevents copy elision |
249+
| Compiler warning (level 4, off) C5264 | '*variable-name*': 'const' variable is not used |
244250
| Compiler warning (level 1, error) C5300 | '#pragma omp atomic': left operand of '*operator*' must match left hand side of assignment-expression |
245251
| Compiler warning (level 1) C5301 | '#pragma omp for': '*symbol*' increases while loop condition uses '*comparison*'; non-terminating loop? |
246252
| Compiler warning (level 1) C5302 | '#pragma omp for': '*symbol*' decreases while loop condition uses '*comparison*'; non-terminating loop? |

0 commit comments

Comments
 (0)