Skip to content

Commit 1aaae44

Browse files
TaojunshenColin Robertsonopbld15TylerMSFTTylerMSFT
authored
8/13/2021 AM Publish (#3723)
* fix code sample (#3676) * fix code sample * acrolinx Co-authored-by: TylerMSFT <[email protected]> * Address 3269 typo in warning number (#3680) * Fixed typo: evalution --> evaluation * Fixed typo: evalution --> evaluation * Bulk Fix - Sentence form for all alt text (#3683) * Updated C/C++ workload name The workload for C/C++ development in VS Build Tools 2019 installer is called 'Desktop development with C++'. * Split out docs by version Add VS2017-specific instructions. * Updated C/C++ workload name The workload for C/C++ development in VS Build Tools 2019 installer is called 'Desktop development with C++'. * Split out docs by version Add VS2017-specific instructions. * Add 16.11 Compiler Warnings C5247 and C5248 (MicrosoftDocs#3689) * Add C5247 and C5248 * Fix link typos * Updates per Xiang Fan review * More wordsmithage * More fix per X.F. * Fix inconsistencies in CMake docs (MicrosoftDocs#3692) * Standard format for CMake docs * Fix markdownlint * More cleanup. * Clean up link issue, acrolinx * Fix more broken things * Undo a change * Add documentation for "unspecified" architecture Add documentation regarding "unspecified" architecture such that it provides an option for someone to ensure that no inherited environment is selected. * Update markdownlint.json file for unordered lists (#3694) Block rule that wants * instead of - to prefix unordered lists, since we've standardized on the latter. Merging on my own recognizance as repo admin. * Clean up documentation for "unspecified" architecture * Markdown quality fixes 1 of N * Markdown quality fixes 2 of N * Markdown quality fixes 3 of N * Markdown quality fixes 4 of N * Markdown quality fixes 5 of N * Markdown quality fixes 6 of N * Markdown quality fixes 7 of N * Markdown quality fixes 8 of N * Markdown quality fixes 9 of N * Markdown quality fixes 10 of N * Undo TN038 * Markdown quality fixes 11 of N * Setting PATH allows DUMPBIN to be executed from the system command prompt. There are multiple DUMPBIN.EXE's in the MSVC folder, but they can be executed if the PATH is set correctly. If this is not true, or undesireable per system design constraints, please clarify otherwise. * Call out toolchains and embedded scenarios * Add link to environment setting instructions * Make more readable * Address cpp-docs 3286 Postfix increment, decrement syntax (MicrosoftDocs#3711) * Address cpp-docs issue 3286 * Fix formatting, final example * Add compiler warning C5243, C5249, C5250 (MicrosoftDocs#3710) * Removing linux and non-windows bullet point * Make clear it's not required to meet all conditions Add "or" to final bullet point * PR review edit, Microsoft style for lists * Make the "unspecified" architecture option more general * Add __SANITIZE_ADDRESS__ to predefined macros page Noticed __SANITIZE_ADDRESS__ was missing from this list. * Add VS version Also note the VS version where __SANITIZE_ADDRESS__ was added in. * Add docs on using existing cache without cmake-server * Fix unescaped <chrono> (MicrosoftDocs#3715) Noticed this while doing other changes. Without being in a code block, <chrono> becomes the html element of the same name. * Address issue 3301 * Create and integrate /Zc:lambda article (#3719) * Create and integrate /Zc:lambda article * Fix conformance topic date * Update cmake-projects-in-visual-studio.md Co-authored-by: Colin Robertson <[email protected]> Co-authored-by: opbld15 <[email protected]> Co-authored-by: Tyler Whitney <[email protected]> Co-authored-by: TylerMSFT <[email protected]> Co-authored-by: opbld17 <[email protected]> Co-authored-by: ystamant <[email protected]> Co-authored-by: opbld16 <[email protected]> Co-authored-by: Andrew Shymanel <[email protected]> Co-authored-by: Garrett Campbell <[email protected]> Co-authored-by: PRMerger6 <[email protected]> Co-authored-by: PRMerger12 <[email protected]> Co-authored-by: PRMerger14 <[email protected]> Co-authored-by: PRMerger16 <[email protected]> Co-authored-by: PRMerger15 <[email protected]> Co-authored-by: PRMerger7 <[email protected]> Co-authored-by: PRMerger10 <[email protected]> Co-authored-by: David Dyck <[email protected]> Co-authored-by: Kristine Toliver <[email protected]> Co-authored-by: Steve Wishnousky <[email protected]> Co-authored-by: Sam Freed <[email protected]> Co-authored-by: Don Spencer <[email protected]>
1 parent a16ac49 commit 1aaae44

File tree

11 files changed

+157
-52
lines changed

11 files changed

+157
-52
lines changed

docs/build/cmake-projects-in-visual-studio.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,13 @@ When you open an existing CMake cache file (*`CMakeCache.txt`*), Visual Studio d
6363

6464
You can add an existing CMake cache to an open project. It's done the same way you'd add a new configuration. For more information, see our blog post on [opening an existing cache in Visual Studio](https://devblogs.microsoft.com/cppblog/open-existing-cmake-caches-in-visual-studio/).
6565

66-
### Advanced CMake cache troubleshooting
66+
> [!NOTE]
67+
> The default existing cache experience relies on `cmake-server`, which was removed from CMake in version 3.20. To continue using existing cache functionality in Visual Studio 2019 version 16.10 and later, take one of these steps:
68+
> - Manually install CMake version 3.19 or lower. Then, set the `cmakeExecutable` property in your existing cache configuration to use that version of CMake.
69+
> - In your existing cache configuration, set the `cacheGenerationCommand` property to let Visual Studio request the necessary CMake file-based API files. For more information on that property, see [CMakeSettings.json reference](cmakesettings-reference.md#configurations).
70+
> - Use a query file to request the CMake file-based API files when generating your cache before it's opened in Visual Studio. For query file instructions, see the next section, [Advanced CMake cache troubleshooting](#advanced).
71+
72+
### <a name="advanced"></a> Advanced CMake cache troubleshooting
6773

6874
Visual Studio uses the CMake [file-based API](https://cmake.org/cmake/help/latest/manual/cmake-file-api.7.html) (in versions 3.14 and later) to populate the editor with information specific to your project structure. For more information, see the C++ team blog post on [multi-root workspaces and file-based API](https://devblogs.microsoft.com/cppblog/visual-studio-code-cmake-tools-extension-multi-root-workspaces-and-file-based-api/).
6975

docs/build/reference/zc-conformance.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: "/Zc (Conformance)"
33
description: "The /Zc conformance compiler options enable or disable support for conforming or backward-compatible behavior."
4-
ms.date: 01/23/2021
4+
ms.date: 08/12/2021
55
helpviewer_keywords: ["/Zc compiler options [C++]", "-Zc compiler options [C++]", "Conformance compiler options", "Zc compiler options [C++]"]
66
---
77
# `/Zc` (Conformance)
@@ -30,6 +30,7 @@ Here are the **`/Zc`** compiler options:
3030
| [`/Zc:hiddenFriend`](zc-hiddenfriend.md) | Enforce Standard C++ hidden friend rules (implied by **`/permissive-`**) |
3131
| [`/Zc:implicitNoexcept`](zc-implicitnoexcept-implicit-exception-specifiers.md) | Enable implicit **`noexcept`** on required functions (on by default). |
3232
| [`/Zc:inline`](zc-inline-remove-unreferenced-comdat.md) | Remove unreferenced functions or data if they're COMDAT or have internal linkage only (off by default). |
33+
| [`/Zc:lambda`](zc-lambda.md) | Enable new lambda processor for conformance-mode syntactic checks in generic lambdas. |
3334
| [`/Zc:noexceptTypes`](zc-noexcepttypes.md) | Enforce C++17 **`noexcept`** rules (on by default in C++17 or later). |
3435
| [`/Zc:preprocessor`](zc-preprocessor.md) | Use the new conforming preprocessor (off by default, except in C11/C17). |
3536
| [`/Zc:referenceBinding`](zc-referencebinding-enforce-reference-binding-rules.md) | A UDT temporary won't bind to a non-const lvalue reference (off by default). |

docs/build/reference/zc-cplusplus.md

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,47 @@
11
---
22
description: "Learn more about: /Zc:__cplusplus (Enable updated __cplusplus macro)"
33
title: "/Zc:__cplusplus (Enable updated __cplusplus macro)"
4-
ms.date: "05/16/2019"
4+
ms.date: 08/11/2021
55
f1_keywords: ["/Zc:__cplusplus"]
66
helpviewer_keywords: ["-Zc:__cplusplus compiler option (C++)", "__cplusplus macro (C++)"]
77
---
8-
# /Zc:__cplusplus (Enable updated __cplusplus macro)
8+
# `/Zc:__cplusplus` (Enable updated `__cplusplus` macro)
99

10-
The **/Zc:__cplusplus** compiler option enables the **\_\_cplusplus** preprocessor macro to report an updated value for recent C++ language standards support. By default, Visual Studio always returns the value "199711L" for the **\_\_cplusplus** preprocessor macro.
10+
The **`/Zc:__cplusplus`** compiler option enables the `__cplusplus` preprocessor macro to report an updated value for recent C++ language standards support. By default, Visual Studio always returns the value `199711L` for the `__cplusplus` preprocessor macro.
1111

1212
## Syntax
1313

14-
> **/Zc:__cplusplus**[**-**]
14+
> **`/Zc:__cplusplus`**[**`-`**]
1515
1616
## Remarks
1717

18-
The **\_\_cplusplus** preprocessor macro is commonly used to report support for a particular version of the C++ standard. Because lots of existing code appears to depend on the value of this macro matching "199711L", the compiler does not change the value of the macro unless you explicitly opt-in by using the **/Zc:__cplusplus** compiler option. The **/Zc:__cplusplus** option is available starting in Visual Studio 2017 version 15.7, and is off by default. In earlier versions of Visual Studio, and by default, or if **/Zc:__cplusplus-** is specified, Visual Studio returns the value "199711L" for the **\_\_cplusplus** preprocessor macro. The [/permissive-](permissive-standards-conformance.md) option does not enable **/Zc:__cplusplus**.
18+
The `__cplusplus` preprocessor macro is commonly used to report support for a particular version of the C++ standard. Because a lot of existing code appears to depend on the value of this macro matching `199711L`, the compiler doesn't change the value of the macro unless you explicitly opt in by using the **`/Zc:__cplusplus`** compiler option. The **`/Zc:__cplusplus`** option is available starting in Visual Studio 2017 version 15.7, and is off by default. In earlier versions of Visual Studio, and by default, or if **`/Zc:__cplusplus-`** is specified, Visual Studio returns the value `199711L` for the `__cplusplus` preprocessor macro. The [`/permissive-`](permissive-standards-conformance.md) option doesn't enable **`/Zc:__cplusplus`**.
1919

20-
When the **/Zc:__cplusplus** option is enabled, the value reported by the **\_\_cplusplus** macro depends on the [/std](std-specify-language-standard-version.md) version switch setting. This table shows the possible values for the macro:
20+
When the **`/Zc:__cplusplus`** option is enabled, the value reported by the `__cplusplus` macro depends on the [`/std`](std-specify-language-standard-version.md) version option setting. This table shows the possible values for the macro:
2121

22-
|/Zc:__cplusplus switch|/std:c++ switch|__cplusplus value|
23-
|-|-|-|
24-
Zc:__cplusplus|/std:c++14 (default)|201402L
25-
Zc:__cplusplus|/std:c++17|201703L
26-
Zc:__cplusplus|/std:c++latest|201704L
27-
Zc:__cplusplus- (disabled)|Any value|199711L
28-
Not specified|Any value|199711L
22+
| `/Zc:__cplusplus` option | `/std` option | `__cplusplus` value |
23+
|--|--|--|
24+
| `Zc:__cplusplus` | `/std:c++14` (default) | `201402L` |
25+
| `Zc:__cplusplus` | `/std:c++17` | `201703L` |
26+
| `Zc:__cplusplus` | `/std:c++20` | `202002L` |
27+
| `Zc:__cplusplus` | `/std:c++latest` | see text |
28+
| `Zc:__cplusplus-` (disabled) | Any value | `199711L` |
29+
| Not specified | Any value | `199711L` |
2930

30-
The compiler does not support standards switches for C++98, C++03, or C++11.
31+
The compiler doesn't support standards options for C++98, C++03, or C++11. The **`/std:c++20`** option is available starting in Visual Studio 2019 version 16.11. The value of `__cplusplus` with the **`/std:c++latest`** option depends on the version of Visual Studio. It's always at least one higher than the highest supported `__cplusplus` standard value supported by your version of Visual Studio.
3132

32-
For finer-grained detection of changes to the compiler toolset, use the [_MSC_VER](../../preprocessor/predefined-macros.md) predefined macro. The value of this built-in macro is incremented for every toolset update in Visual Studio 2017 and later versions. The [_MSVC_LANG](../../preprocessor/predefined-macros.md) predefined macro reports the standard version whether the **/Zc:__cplusplus** option is enabled or disabled. When **/Zc:__cplusplus** is enabled, `__cplusplus == _MSVC_LANG`.
33+
For finer-grained detection of changes to the compiler toolset, use the [`_MSC_VER`](../../preprocessor/predefined-macros.md) predefined macro. The value of this built-in macro is incremented for every toolset update in Visual Studio 2017 and later versions. The [`_MSVC_LANG`](../../preprocessor/predefined-macros.md) predefined macro reports the standard version whether the **`/Zc:__cplusplus`** option is enabled or disabled. When **`/Zc:__cplusplus`** is enabled, `__cplusplus` has the same value as `_MSVC_LANG`.
3334

3435
### To set this compiler option in Visual Studio
3536

3637
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).
3738

3839
1. Select the **Configuration Properties** > **C/C++** > **Command Line** property page.
3940

40-
1. Add **/Zc:__cplusplus** or **/Zc:__cplusplus-** to the **Additional options:** pane.
41+
1. Add **`/Zc:__cplusplus`** or **`/Zc:__cplusplus-`** to the **Additional options:** pane.
4142

4243
## See also
4344

44-
- [/Zc (Conformance)](zc-conformance.md)
45-
- [/std (Specify language standard version)](std-specify-language-standard-version.md)
46-
- [Predefined macros](../../preprocessor/predefined-macros.md)
45+
[`/Zc` (Conformance)](zc-conformance.md)\
46+
[`/std` (Specify language standard version)](std-specify-language-standard-version.md)\
47+
[Predefined macros](../../preprocessor/predefined-macros.md)

docs/build/reference/zc-lambda.md

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
---
2+
description: "Learn more about: /Zc:lambda (Enable updated lambda processor)"
3+
title: "/Zc:lambda (Enable updated lambda processor)"
4+
ms.date: 08/11/2021
5+
f1_keywords: ["/Zc:lambda"]
6+
helpviewer_keywords: ["-Zc:lambda compiler option (C++)", "/Zc:lambda compiler option (C++)"]
7+
---
8+
# `/Zc:lambda` (Enable updated lambda processor)
9+
10+
The **`/Zc:lambda`** compiler option enables conforming lambda grammar and processing support.
11+
12+
## Syntax
13+
14+
> **`/Zc:lambda`**[**`-`**]
15+
16+
## Remarks
17+
18+
The **`/Zc:lambda`** compiler option enables the conforming lambda processor. It parses and implements lambda code according to the C++ standard. This option is off by default, which uses the legacy lambda processor. Use this option to enable conformance-mode syntax checks of generic lambdas when you use the default [`/std:c++14`](std-specify-language-standard-version.md) or the [`/std:c++17`](std-specify-language-standard-version.md) compiler options.
19+
20+
**`/Zc:lambda`** is automatically enabled by the [`/std:c++20`](std-specify-language-standard-version.md), [`/std:c++latest`](std-specify-language-standard-version.md), and [`/experimental:module`](experimental-module.md) options. You can disable it explicitly by using **`/Zc:lambda-`**. The [`/permissive-`](permissive-standards-conformance.md) option doesn't enable **`/Zc:lambda`**.
21+
22+
The **`/Zc:lambda`** option is available starting in Visual Studio 2019 version 16.8. It's available as **`/experimental:newLambdaProcessor`** starting in Visual Studio 2019 version 16.3, but this spelling is now deprecated.
23+
24+
The legacy lambda processor has limitations when it parses and compiles lambdas. For example, this conforming code compiles correctly under **`/Zc:lambda`**, but reports errors under **`/Zc:lambda-`**:
25+
26+
```cpp
27+
void f1()
28+
{
29+
constexpr auto c_value = 1;
30+
auto func = []()
31+
{
32+
return c_value; // error C3493: 'c_value' cannot be implicitly captured
33+
// because no default capture mode has been specified
34+
};
35+
func(); // error C2064: term does not evaluate to a function taking 0 arguments
36+
}
37+
```
38+
39+
The legacy lambda processor compiles this code without warnings, but the new lambda processor produces error C2760:
40+
41+
```cpp
42+
void f2() {
43+
auto a = [](auto arg) {
44+
decltype(arg)::Type t; // C2760 syntax error: unexpected token 'identifier', expected ';'
45+
};
46+
}
47+
```
48+
49+
This example shows the correct syntax, now enforced by the compiler under **`/Zc:lambda`**:
50+
51+
```cpp
52+
void f3() {
53+
auto a = [](auto arg) {
54+
typename decltype(arg)::Type t;
55+
};
56+
}
57+
```
58+
59+
### To set this compiler option in Visual Studio
60+
61+
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).
62+
63+
1. Select the **Configuration Properties** > **C/C++** > **Command Line** property page.
64+
65+
1. Add **`/Zc:lambda`** or **`/Zc:lambda-`** to the **Additional options:** pane.
66+
67+
## See also
68+
69+
[`/Zc` (Conformance)](zc-conformance.md)\
70+
[`/std` (Specify language standard version)](std-specify-language-standard-version.md)

docs/build/toc.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -773,6 +773,9 @@
773773
href: ../build/reference/zc-implicitnoexcept-implicit-exception-specifiers.md
774774
- name: "/Zc:inline (Remove unreferenced COMDAT)"
775775
href: ../build/reference/zc-inline-remove-unreferenced-comdat.md
776+
- name: "/Zc:lambda (Enable updated lambda processor)"
777+
href: ../build/reference/zc-lambda.md
778+
- name: "/Zc:preprocessor (Enable preprocessor conformance mode)"
776779
- name: "/Zc:noexceptTypes (C++17 noexcept rules)"
777780
href: ../build/reference/zc-noexcepttypes.md
778781
- name: "/Zc:preprocessor (Enable preprocessor conformance mode)"

0 commit comments

Comments
 (0)