Skip to content

Commit 742170c

Browse files
Merge pull request #4665 from corob-msft/release-17.4-1
17.4 Release updates
2 parents da06c1c + 59d8ae2 commit 742170c

11 files changed

+438
-36
lines changed

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 `enum` type deduction (off by default). |
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). |

docs/build/reference/zc-enumtypes.md

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 enum type deduction)"
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 __STDC__ macro) compiler option."
3+
title: "/Zc:__STDC__ (Enable __STDC__ macro)"
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__` (Enable `__STDC__` macro)
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/build/toc.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -769,14 +769,18 @@ items:
769769
items:
770770
- name: /Zc (Conformance)
771771
href: ../build/reference/zc-conformance.md
772+
- name: "/Zc:__cplusplus (Enable updated __cplusplus macro)"
773+
href: ../build/reference/zc-cplusplus.md
774+
- name: "/Zc:__STDC__ (Enable __STDC__ macro)"
775+
href: ../build/reference/zc-stdc.md
772776
- name: "/Zc:alignedNew (C++17 over-aligned allocation)"
773777
href: ../build/reference/zc-alignednew.md
774778
- name: "/Zc:auto (Deduce variable type)"
775779
href: ../build/reference/zc-auto-deduce-variable-type.md
776780
- name: "/Zc:char8_t (Enable C++20 char8_t type)"
777781
href: ../build/reference/zc-char8-t.md
778-
- name: "/Zc:__cplusplus (Enable updated __cplusplus macro)"
779-
href: ../build/reference/zc-cplusplus.md
782+
- name: '/Zc:enumTypes (Enable enum type deduction)'
783+
href: ../build/reference/zc-enumtypes.md
780784
- name: '/Zc:externC (Use Standard C++ extern "C" rules)'
781785
href: ../build/reference/zc-externc.md
782786
- name: "/Zc:externConstexpr (Enable extern constexpr variables)"

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`**.

0 commit comments

Comments
 (0)