From 1aaae446ae6ee15390ad106b904b4d8e083a2e5a Mon Sep 17 00:00:00 2001 From: Taojunshen Date: Sat, 14 Aug 2021 01:51:29 +0800 Subject: [PATCH] 8/13/2021 AM Publish (#3723) * fix code sample (#3676) * fix code sample * acrolinx Co-authored-by: TylerMSFT * 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 (#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 (#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 (#3711) * Address cpp-docs issue 3286 * Fix formatting, final example * Add compiler warning C5243, C5249, C5250 (#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 (#3715) Noticed this while doing other changes. Without being in a code block, 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 Co-authored-by: opbld15 Co-authored-by: Tyler Whitney Co-authored-by: TylerMSFT Co-authored-by: opbld17 Co-authored-by: ystamant <49958001+ystamant@users.noreply.github.com> Co-authored-by: opbld16 Co-authored-by: Andrew Shymanel <88244804+ainrd@users.noreply.github.com> Co-authored-by: Garrett Campbell <86264750+gcampbell-msft@users.noreply.github.com> Co-authored-by: PRMerger6 Co-authored-by: PRMerger12 Co-authored-by: PRMerger14 Co-authored-by: PRMerger16 Co-authored-by: PRMerger15 Co-authored-by: PRMerger7 Co-authored-by: PRMerger10 Co-authored-by: David Dyck Co-authored-by: Kristine Toliver Co-authored-by: Steve Wishnousky Co-authored-by: Sam Freed Co-authored-by: Don Spencer <87099566+v-donspencer@users.noreply.github.com> --- docs/build/cmake-projects-in-visual-studio.md | 8 ++- docs/build/reference/zc-conformance.md | 3 +- docs/build/reference/zc-cplusplus.md | 39 ++++++----- docs/build/reference/zc-lambda.md | 70 +++++++++++++++++++ docs/build/toc.yml | 3 + docs/cpp/program-and-linkage-cpp.md | 28 ++++---- .../compiler-errors-2/compiler-error-c2760.md | 26 ++++++- docs/overview/cpp-conformance-improvements.md | 6 +- ...t-s-new-for-visual-cpp-in-visual-studio.md | 2 +- docs/preprocessor/predefined-macros.md | 8 ++- docs/standard-library/chrono.md | 16 ++--- 11 files changed, 157 insertions(+), 52 deletions(-) create mode 100644 docs/build/reference/zc-lambda.md diff --git a/docs/build/cmake-projects-in-visual-studio.md b/docs/build/cmake-projects-in-visual-studio.md index a3a11e33e53..428ab1318bc 100644 --- a/docs/build/cmake-projects-in-visual-studio.md +++ b/docs/build/cmake-projects-in-visual-studio.md @@ -63,7 +63,13 @@ When you open an existing CMake cache file (*`CMakeCache.txt`*), Visual Studio d 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/). -### Advanced CMake cache troubleshooting +> [!NOTE] +> 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: +> - Manually install CMake version 3.19 or lower. Then, set the `cmakeExecutable` property in your existing cache configuration to use that version of CMake. +> - 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). +> - 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). + +### Advanced CMake cache troubleshooting 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/). diff --git a/docs/build/reference/zc-conformance.md b/docs/build/reference/zc-conformance.md index 43e2dcd811e..6f4c29ada9f 100644 --- a/docs/build/reference/zc-conformance.md +++ b/docs/build/reference/zc-conformance.md @@ -1,7 +1,7 @@ --- title: "/Zc (Conformance)" description: "The /Zc conformance compiler options enable or disable support for conforming or backward-compatible behavior." -ms.date: 01/23/2021 +ms.date: 08/12/2021 helpviewer_keywords: ["/Zc compiler options [C++]", "-Zc compiler options [C++]", "Conformance compiler options", "Zc compiler options [C++]"] --- # `/Zc` (Conformance) @@ -30,6 +30,7 @@ Here are the **`/Zc`** compiler options: | [`/Zc:hiddenFriend`](zc-hiddenfriend.md) | Enforce Standard C++ hidden friend rules (implied by **`/permissive-`**) | | [`/Zc:implicitNoexcept`](zc-implicitnoexcept-implicit-exception-specifiers.md) | Enable implicit **`noexcept`** on required functions (on by default). | | [`/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). | +| [`/Zc:lambda`](zc-lambda.md) | Enable new lambda processor for conformance-mode syntactic checks in generic lambdas. | | [`/Zc:noexceptTypes`](zc-noexcepttypes.md) | Enforce C++17 **`noexcept`** rules (on by default in C++17 or later). | | [`/Zc:preprocessor`](zc-preprocessor.md) | Use the new conforming preprocessor (off by default, except in C11/C17). | | [`/Zc:referenceBinding`](zc-referencebinding-enforce-reference-binding-rules.md) | A UDT temporary won't bind to a non-const lvalue reference (off by default). | diff --git a/docs/build/reference/zc-cplusplus.md b/docs/build/reference/zc-cplusplus.md index 57f3f1f0998..ef73099605f 100644 --- a/docs/build/reference/zc-cplusplus.md +++ b/docs/build/reference/zc-cplusplus.md @@ -1,35 +1,36 @@ --- description: "Learn more about: /Zc:__cplusplus (Enable updated __cplusplus macro)" title: "/Zc:__cplusplus (Enable updated __cplusplus macro)" -ms.date: "05/16/2019" +ms.date: 08/11/2021 f1_keywords: ["/Zc:__cplusplus"] helpviewer_keywords: ["-Zc:__cplusplus compiler option (C++)", "__cplusplus macro (C++)"] --- -# /Zc:__cplusplus (Enable updated __cplusplus macro) +# `/Zc:__cplusplus` (Enable updated `__cplusplus` macro) -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. +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. ## Syntax -> **/Zc:__cplusplus**[**-**] +> **`/Zc:__cplusplus`**[**`-`**] ## Remarks -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**. +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`**. -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: +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: -|/Zc:__cplusplus switch|/std:c++ switch|__cplusplus value| -|-|-|-| -Zc:__cplusplus|/std:c++14 (default)|201402L -Zc:__cplusplus|/std:c++17|201703L -Zc:__cplusplus|/std:c++latest|201704L -Zc:__cplusplus- (disabled)|Any value|199711L -Not specified|Any value|199711L +| `/Zc:__cplusplus` option | `/std` option | `__cplusplus` value | +|--|--|--| +| `Zc:__cplusplus` | `/std:c++14` (default) | `201402L` | +| `Zc:__cplusplus` | `/std:c++17` | `201703L` | +| `Zc:__cplusplus` | `/std:c++20` | `202002L` | +| `Zc:__cplusplus` | `/std:c++latest` | see text | +| `Zc:__cplusplus-` (disabled) | Any value | `199711L` | +| Not specified | Any value | `199711L` | -The compiler does not support standards switches for C++98, C++03, or C++11. +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. -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`. +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`. ### To set this compiler option in Visual Studio @@ -37,10 +38,10 @@ For finer-grained detection of changes to the compiler toolset, use the [_MSC_VE 1. Select the **Configuration Properties** > **C/C++** > **Command Line** property page. -1. Add **/Zc:__cplusplus** or **/Zc:__cplusplus-** to the **Additional options:** pane. +1. Add **`/Zc:__cplusplus`** or **`/Zc:__cplusplus-`** to the **Additional options:** pane. ## See also -- [/Zc (Conformance)](zc-conformance.md) -- [/std (Specify language standard version)](std-specify-language-standard-version.md) -- [Predefined macros](../../preprocessor/predefined-macros.md) +[`/Zc` (Conformance)](zc-conformance.md)\ +[`/std` (Specify language standard version)](std-specify-language-standard-version.md)\ +[Predefined macros](../../preprocessor/predefined-macros.md) diff --git a/docs/build/reference/zc-lambda.md b/docs/build/reference/zc-lambda.md new file mode 100644 index 00000000000..6c2e3080ec3 --- /dev/null +++ b/docs/build/reference/zc-lambda.md @@ -0,0 +1,70 @@ +--- +description: "Learn more about: /Zc:lambda (Enable updated lambda processor)" +title: "/Zc:lambda (Enable updated lambda processor)" +ms.date: 08/11/2021 +f1_keywords: ["/Zc:lambda"] +helpviewer_keywords: ["-Zc:lambda compiler option (C++)", "/Zc:lambda compiler option (C++)"] +--- +# `/Zc:lambda` (Enable updated lambda processor) + +The **`/Zc:lambda`** compiler option enables conforming lambda grammar and processing support. + +## Syntax + +> **`/Zc:lambda`**[**`-`**] + +## Remarks + +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. + +**`/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`**. + +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. + +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-`**: + +```cpp +void f1() +{ + constexpr auto c_value = 1; + auto func = []() + { + return c_value; // error C3493: 'c_value' cannot be implicitly captured + // because no default capture mode has been specified + }; + func(); // error C2064: term does not evaluate to a function taking 0 arguments +} +``` + +The legacy lambda processor compiles this code without warnings, but the new lambda processor produces error C2760: + +```cpp +void f2() { + auto a = [](auto arg) { + decltype(arg)::Type t; // C2760 syntax error: unexpected token 'identifier', expected ';' + }; +} +``` + +This example shows the correct syntax, now enforced by the compiler under **`/Zc:lambda`**: + +```cpp +void f3() { + auto a = [](auto arg) { + typename decltype(arg)::Type t; + }; +} +``` + +### To set this compiler option in Visual Studio + +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. Select the **Configuration Properties** > **C/C++** > **Command Line** property page. + +1. Add **`/Zc:lambda`** or **`/Zc:lambda-`** to the **Additional options:** pane. + +## See also + +[`/Zc` (Conformance)](zc-conformance.md)\ +[`/std` (Specify language standard version)](std-specify-language-standard-version.md) diff --git a/docs/build/toc.yml b/docs/build/toc.yml index 61d159cb6a4..7e8ef685e1b 100644 --- a/docs/build/toc.yml +++ b/docs/build/toc.yml @@ -773,6 +773,9 @@ href: ../build/reference/zc-implicitnoexcept-implicit-exception-specifiers.md - name: "/Zc:inline (Remove unreferenced COMDAT)" href: ../build/reference/zc-inline-remove-unreferenced-comdat.md + - name: "/Zc:lambda (Enable updated lambda processor)" + href: ../build/reference/zc-lambda.md + - name: "/Zc:preprocessor (Enable preprocessor conformance mode)" - name: "/Zc:noexceptTypes (C++17 noexcept rules)" href: ../build/reference/zc-noexcepttypes.md - name: "/Zc:preprocessor (Enable preprocessor conformance mode)" diff --git a/docs/cpp/program-and-linkage-cpp.md b/docs/cpp/program-and-linkage-cpp.md index c6379636a79..7f9e6cc9a5e 100644 --- a/docs/cpp/program-and-linkage-cpp.md +++ b/docs/cpp/program-and-linkage-cpp.md @@ -1,12 +1,12 @@ --- description: "Learn more about: Translation units and linkage" title: "Translation units and linkage (C++)" -ms.date: "12/11/2019" +ms.date: 08/12/2021 ms.assetid: a6493ba0-24e2-4c89-956e-9da1dea660cb --- # Translation units and linkage -In a C++ program, a *symbol*, for example a variable or function name, can be declared any number of times within its scope, but it can only be defined once. This rule is the "One Definition Rule" (ODR). A *declaration* introduces (or re-introduces) a name into the program. A *definition* introduces a name. If the name represents a variable, a definition explicitly initializes it. A *function definition* consists of the signature plus the function body. A class definition consists of the class name followed by a block that lists all the class members. (The bodies of member functions may optionally be defined separately in another file.) +In a C++ program, a *symbol*, for example a variable or function name, can be declared any number of times within its scope. However, it can only be defined once. This rule is the "One Definition Rule" (ODR). A *declaration* introduces (or reintroduces) a name into the program, along with enough information to later associate the name with a definition. A *definition* introduces a name and provides all the information needed to create it. If the name represents a variable, a definition explicitly creates storage and initializes it. A *function definition* consists of the signature plus the function body. A class definition consists of the class name followed by a block that lists all the class members. (The bodies of member functions may optionally be defined separately in another file.) The following example shows some declarations: @@ -27,35 +27,35 @@ public: }; ``` -A program consists of one or more *translation units*. A translation unit consists of an implementation file and all the headers that it includes directly or indirectly. Implementation files typically have a file extension of *cpp* or *cxx*. Header files typically have an extension of *h* or *hpp*. Each translation unit is compiled independently by the compiler. After the compilation is complete, the linker merges the compiled translation units into a single *program*. Violations of the ODR rule typically show up as linker errors. Linker errors occur when the same name has two different definitions in different translation units. +A program consists of one or more *translation units*. A translation unit consists of an implementation file and all the headers that it includes directly or indirectly. Implementation files typically have a file extension of *`.cpp`* or *`.cxx`*. Header files typically have an extension of *`.h`* or *`.hpp`*. Each translation unit is compiled independently by the compiler. After the compilation is complete, the linker merges the compiled translation units into a single *program*. Violations of the ODR rule typically show up as linker errors. Linker errors occur when the same name has two different definitions in different translation units. -In general, the best way to make a variable visible across multiple files is to put it in a header file. Then add an #include directive in every *cpp* file that requires the declaration. By adding *include guards* around the header contents, you ensure that the names it declares are only defined once. +In general, the best way to make a variable visible across multiple files is to put it in a header file. Then add an #include directive in every *`.cpp`* file that requires the declaration. By adding *include guards* around the header contents, you ensure that the names it declares are only defined once. In C++20, [modules](modules-cpp.md) are introduced as an improved alternative to header files. -In some cases it may be necessary to declare a global variable or class in a *cpp* file. In those cases, you need a way to tell the compiler and linker what kind of *linkage* the name has. The type of linkage specifies whether the name of the object applies just to the one file, or to all files. The concept of linkage applies only to global names. The concept of linkage does not apply to names that are declared within a scope. A scope is specified by a set of enclosing braces such as in function or class definitions. +In some cases, it may be necessary to declare a global variable or class in a *`.cpp`* file. In those cases, you need a way to tell the compiler and linker what kind of *linkage* the name has. The type of linkage specifies whether the name of the object applies just to the one file, or to all files. The concept of linkage applies only to global names. The concept of linkage doesn't apply to names that are declared within a scope. A scope is specified by a set of enclosing braces such as in function or class definitions. ## External vs. internal linkage -A *free function* is a function that is defined at global or namespace scope. Non-const global variables and free functions by default have *external linkage*; they are visible from any translation unit in the program. Therefore, no other global object can have that name. A symbol with *internal linkage* or *no linkage* is visible only within the translation unit in which it is declared. When a name has internal linkage, the same name may exist in another translation unit. Variables declared within class definitions or function bodies have no linkage. +A *free function* is a function that is defined at global or namespace scope. Non-const global variables and free functions by default have *external linkage*; they're visible from any translation unit in the program. No other global object can have that name. A symbol with *internal linkage* or *no linkage* is visible only within the translation unit in which it's declared. When a name has internal linkage, the same name may exist in another translation unit. Variables declared within class definitions or function bodies have no linkage. -You can force a global name to have internal linkage by explicitly declaring it as **`static`**. This limits its visibility to the same translation unit in which it is declared. In this context, **`static`** means something different than when applied to local variables. +You can force a global name to have internal linkage by explicitly declaring it as **`static`**. This keyword limits its visibility to the same translation unit in which it's declared. In this context, **`static`** means something different than when applied to local variables. The following objects have internal linkage by default: -- const objects -- constexpr objects -- typedefs -- static objects in namespace scope +- **`const`** objects +- **`constexpr`** objects +- **`typedef`** objects +- **`static`** objects in namespace scope -To give a const object external linkage, declare it as **`extern`** and assign it a value: +To give a **`const`** object external linkage, declare it as **`extern`** and assign it a value: ```cpp extern const int value = 42; ``` -See [extern](extern-cpp.md) for more information. +For more information, see [`extern`](extern-cpp.md). ## See also -[Basic Concepts](../cpp/basic-concepts-cpp.md) +[Basic concepts](../cpp/basic-concepts-cpp.md) diff --git a/docs/error-messages/compiler-errors-2/compiler-error-c2760.md b/docs/error-messages/compiler-errors-2/compiler-error-c2760.md index fd8eb81e97e..e33c5a9552a 100644 --- a/docs/error-messages/compiler-errors-2/compiler-error-c2760.md +++ b/docs/error-messages/compiler-errors-2/compiler-error-c2760.md @@ -1,14 +1,16 @@ --- description: "Learn more about: Compiler Error C2760" title: "Compiler Error C2760" -ms.date: "11/04/2016" +ms.date: 08/12/2021 f1_keywords: ["C2760"] helpviewer_keywords: ["C2760"] ms.assetid: 585757fd-d519-43f3-94e5-50316ac8b90b --- # Compiler Error C2760 -> syntax error : expected '*name1*' not '*name2*' +> syntax error : expected '*name1*' not '*name2*'\ +> syntax error : unexpected token '*token1*', expected '*token2*'\ +> syntax error: '*token1*' was unexpected here; expected '*token2*' ## Remarks @@ -29,3 +31,23 @@ void f(B* pb) { D* pd3 = static_cast(i); ### Syntax checks for generic lambdas -The new lambda processor enables some conformance-mode syntactic checks in generic lambdas, under [`/std:c++latest`](../build/reference/std-specify-language-standard-version.md) or under any other language mode with **`/experimental:newLambdaProcessor`**. +The new lambda processor enables some conformance-mode syntactic checks in generic lambdas, under [`/std:c++latest`](../build/reference/std-specify-language-standard-version.md) or under any other language mode with [`/Zc:lambda`](../build/reference/zc-lambda.md) in Visual Studio 2019 version 16.9 or later (previously available as **`/experimental:newLambdaProcessor`** beginning in Visual Studio 2019 version 16.3). -In Visual Studio 2017, this code compiles without warnings, but in Visual Studio 2019 it produces error C2760: +The legacy lambda processor compiles this example without warnings, but the new lambda processor produces error C2760: ```cpp void f() { @@ -505,7 +505,7 @@ void f() { } ``` -The following example shows the correct syntax, now enforced by the compiler: +This example shows the correct syntax, now enforced by the compiler: ```cpp void f() { diff --git a/docs/overview/what-s-new-for-visual-cpp-in-visual-studio.md b/docs/overview/what-s-new-for-visual-cpp-in-visual-studio.md index ec2a9310123..593484205e2 100644 --- a/docs/overview/what-s-new-for-visual-cpp-in-visual-studio.md +++ b/docs/overview/what-s-new-for-visual-cpp-in-visual-studio.md @@ -252,7 +252,7 @@ For a summary of new features and bug fixes in Visual Studio version 16.1, see [ - Increased ability to find function templates via argument-dependent lookup for function call expressions with explicit template arguments ([P0846R0](http://wg21.link/p0846r0)). - Designated initialization ([P0329R4](https://wg21.link/p0329r4)), which allows specific members to be selected in aggregate initialization, for example, by using the `Type t { .member = expr }` syntax. -- Lambda support has been overhauled, addressing a large number of long-standing bugs. This change is enabled by default when using **`/std:c++latest`**. In **`/std:c++17`** language mode and under the default (**`/std:c++14`** ) mode, the new parser can be enabled by using **`/experimental:newLambdaProcessor`**, for example, `/std:c++17 /experimental:newLambdaProcessor`. +- Lambda support has been overhauled, addressing a large number of long-standing bugs. This change is enabled by default when using **`/std:c++20`** or **`/std:c++latest`**. In **`/std:c++17`** language mode and under the default (**`/std:c++14`** ) mode, the new parser can be enabled by using [`/Zc:lambda`](../build/reference/zc-lambda.md) in Visual Studio 2019 version 16.9 or later (previously available as **`/experimental:newLambdaProcessor`** beginning in Visual Studio 2019 version 16.3), for example, `/std:c++17 /Zc:lambda`. ### C++ standard library improvements diff --git a/docs/preprocessor/predefined-macros.md b/docs/preprocessor/predefined-macros.md index e7d1619052c..07cb6d97e61 100644 --- a/docs/preprocessor/predefined-macros.md +++ b/docs/preprocessor/predefined-macros.md @@ -3,10 +3,10 @@ title: "Predefined macros" description: "Lists and describes the Microsoft C++ compiler predefined preprocessor macros." ms.custom: "update_every_version" ms.date: 06/07/2021 -f1_keywords: ["_ATL_VER", "__ATOM__", "__AVX__", "__AVX2__", "__AVX512BW__", "__AVX512CD__", "__AVX512DQ__", "__AVX512F__", "__AVX512VL__", "_CHAR_UNSIGNED", "__CLR_VER", "_CONTROL_FLOW_GUARD", "__COUNTER__", "__cplusplus", "__cplusplus_cli", "__cplusplus_winrt", "_CPPRTTI", "_CPPUNWIND", "__DATE__", "_DEBUG", "_DLL", "__FILE__", "__FUNCDNAME__", "__FUNCSIG__", "__FUNCTION__", "_INTEGRAL_MAX_BITS", "_ISO_VOLATILE", "_KERNEL_MODE", "__LINE__", "_M_AMD64", "_M_ARM", "_M_ARM_ARMV7VE", "_M_ARM_FP", "_M_ARM64", "_M_CEE", "_M_CEE_PURE", "_M_CEE_SAFE", "_M_FP_EXCEPT", "_M_FP_FAST", "_M_FP_PRECISE", "_M_FP_STRICT", "_M_IX86", "_M_IX86_FP", "_M_X64", "_MANAGED", "_MFC_VER", "_MSC_BUILD", "_MSC_EXTENSIONS", "_MSC_FULL_VER", "_MSC_VER", "_MSVC_LANG", "__MSVC_RUNTIME_CHECKS", "_MT", "_NATIVE_WCHAR_T_DEFINED", "_NO_SIZED_DEALLOCATION", "_OPENMP", "_PREFAST_", "_RESUMABLE_FUNCTIONS_SUPPORTED", "_RTC_CONVERSION_CHECKS_ENABLED", "__STDC__", "__STDC_HOSTED__", "__STDC_NO_ATOMICS__", "__STDC_NO_COMPLEX__", "__STDC_NO_THREADS__", "__STDC_NO_VLA__", "__STDC_VERSION__", "__STDCPP_THREADS__", "__TIME__", "__TIMESTAMP__", "__VA_ARGS__", "_VC_NODEFAULTLIB", "_WCHAR_T_DEFINED", "_WIN32", "_WIN64", "_WINRT_DLL"] -helpviewer_keywords: ["timestamps, preprocessor macro", "cl.exe compiler, version number", "version numbers, C/C++ compiler (cl.exe)", "macros, predefined C++", "preprocessor, macros", "predefined macros", "_ATL_VER macro", "__ATOM__ macro", "__AVX__ macro", "__AVX2__ macro", "__AVX512BW__ macro", "__AVX512CD__ macro", "__AVX512DQ__ macro", "__AVX512F__ macro", "__AVX512VL__ macro", "_CHAR_UNSIGNED macro", "__CLR_VER macro", "_CONTROL_FLOW_GUARD macro", "__COUNTER__ macro", "__cplusplus macro", "__cplusplus_cli macro", "__cplusplus_winrt macro", "_CPPRTTI macro", "_CPPUNWIND macro", "__DATE__ macro", "_DEBUG macro", "_DLL macro", "__FILE__ macro", "__FUNCDNAME__ macro", "__FUNCSIG__ macro", "__FUNCTION__ macro", "_INTEGRAL_MAX_BITS macro", "_ISO_VOLATILE macro", "_KERNEL_MODE macro", "__LINE__ macro", "_M_AMD64 macro", "_M_ARM macro", "_M_ARM_ARMV7VE macro", "_M_ARM_FP macro", "_M_ARM64 macro", "_M_CEE macro", "_M_CEE_PURE macro", "_M_CEE_SAFE macro", "_M_FP_EXCEPT macro", "_M_FP_FAST macro", "_M_FP_PRECISE macro", "_M_FP_STRICT macro", "_M_IX86 macro", "_M_IX86_FP macro", "_M_X64 macro", "_MANAGED macro", "_MFC_VER macro", "_MSC_BUILD macro", "_MSC_EXTENSIONS macro", "_MSC_FULL_VER macro", "_MSC_VER macro", "_MSVC_LANG macro", "__MSVC_RUNTIME_CHECKS macro", "_MT macro", "_NATIVE_WCHAR_T_DEFINED macro", "_NO_SIZED_DEALLOCATION macro", "_OPENMP macro", "_PREFAST_ macro", "_RESUMABLE_FUNCTIONS_SUPPORTED macro", "_RTC_CONVERSION_CHECKS_ENABLED macro", "__STDC__ macro", "__STDC_HOSTED__ macro", "__STDC_NO_ATOMICS__ macro", "__STDC_NO_COMPLEX__ macro", "__STDC_NO_THREADS__ macro", "__STDC_NO_VLA__ macro", "__STDC_VERSION__ macro", "__STDCPP_THREADS__ macro", "__TIME__ macro", "__TIMESTAMP__ macro", "__VA_ARGS__ macro", "_VC_NODEFAULTLIB macro", "_WCHAR_T_DEFINED macro", "_WIN32 macro", "_WIN64 macro", "_WINRT_DLL macro", "__func__ identifier"] +f1_keywords: ["_ATL_VER", "__ATOM__", "__AVX__", "__AVX2__", "__AVX512BW__", "__AVX512CD__", "__AVX512DQ__", "__AVX512F__", "__AVX512VL__", "_CHAR_UNSIGNED", "__CLR_VER", "_CONTROL_FLOW_GUARD", "__COUNTER__", "__cplusplus", "__cplusplus_cli", "__cplusplus_winrt", "_CPPRTTI", "_CPPUNWIND", "__DATE__", "_DEBUG", "_DLL", "__FILE__", "__FUNCDNAME__", "__FUNCSIG__", "__FUNCTION__", "_INTEGRAL_MAX_BITS", "_ISO_VOLATILE", "_KERNEL_MODE", "__LINE__", "_M_AMD64", "_M_ARM", "_M_ARM_ARMV7VE", "_M_ARM_FP", "_M_ARM64", "_M_CEE", "_M_CEE_PURE", "_M_CEE_SAFE", "_M_FP_EXCEPT", "_M_FP_FAST", "_M_FP_PRECISE", "_M_FP_STRICT", "_M_IX86", "_M_IX86_FP", "_M_X64", "_MANAGED", "_MFC_VER", "_MSC_BUILD", "_MSC_EXTENSIONS", "_MSC_FULL_VER", "_MSC_VER", "_MSVC_LANG", "__MSVC_RUNTIME_CHECKS", "_MT", "_NATIVE_WCHAR_T_DEFINED", "_NO_SIZED_DEALLOCATION", "_OPENMP", "_PREFAST_", "_RESUMABLE_FUNCTIONS_SUPPORTED", "_RTC_CONVERSION_CHECKS_ENABLED", "__SANITIZE_ADDRESS__", "__STDC__", "__STDC_HOSTED__", "__STDC_NO_ATOMICS__", "__STDC_NO_COMPLEX__", "__STDC_NO_THREADS__", "__STDC_NO_VLA__", "__STDC_VERSION__", "__STDCPP_THREADS__", "__TIME__", "__TIMESTAMP__", "__VA_ARGS__", "_VC_NODEFAULTLIB", "_WCHAR_T_DEFINED", "_WIN32", "_WIN64", "_WINRT_DLL"] +helpviewer_keywords: ["timestamps, preprocessor macro", "cl.exe compiler, version number", "version numbers, C/C++ compiler (cl.exe)", "macros, predefined C++", "preprocessor, macros", "predefined macros", "_ATL_VER macro", "__ATOM__ macro", "__AVX__ macro", "__AVX2__ macro", "__AVX512BW__ macro", "__AVX512CD__ macro", "__AVX512DQ__ macro", "__AVX512F__ macro", "__AVX512VL__ macro", "_CHAR_UNSIGNED macro", "__CLR_VER macro", "_CONTROL_FLOW_GUARD macro", "__COUNTER__ macro", "__cplusplus macro", "__cplusplus_cli macro", "__cplusplus_winrt macro", "_CPPRTTI macro", "_CPPUNWIND macro", "__DATE__ macro", "_DEBUG macro", "_DLL macro", "__FILE__ macro", "__FUNCDNAME__ macro", "__FUNCSIG__ macro", "__FUNCTION__ macro", "_INTEGRAL_MAX_BITS macro", "_ISO_VOLATILE macro", "_KERNEL_MODE macro", "__LINE__ macro", "_M_AMD64 macro", "_M_ARM macro", "_M_ARM_ARMV7VE macro", "_M_ARM_FP macro", "_M_ARM64 macro", "_M_CEE macro", "_M_CEE_PURE macro", "_M_CEE_SAFE macro", "_M_FP_EXCEPT macro", "_M_FP_FAST macro", "_M_FP_PRECISE macro", "_M_FP_STRICT macro", "_M_IX86 macro", "_M_IX86_FP macro", "_M_X64 macro", "_MANAGED macro", "_MFC_VER macro", "_MSC_BUILD macro", "_MSC_EXTENSIONS macro", "_MSC_FULL_VER macro", "_MSC_VER macro", "_MSVC_LANG macro", "__MSVC_RUNTIME_CHECKS macro", "_MT macro", "_NATIVE_WCHAR_T_DEFINED macro", "_NO_SIZED_DEALLOCATION macro", "_OPENMP macro", "_PREFAST_ macro", "_RESUMABLE_FUNCTIONS_SUPPORTED macro", "_RTC_CONVERSION_CHECKS_ENABLED macro", "__SANITIZE_ADDRESS__ macro", "__STDC__ macro", "__STDC_HOSTED__ macro", "__STDC_NO_ATOMICS__ macro", "__STDC_NO_COMPLEX__ macro", "__STDC_NO_THREADS__ macro", "__STDC_NO_VLA__ macro", "__STDC_VERSION__ macro", "__STDCPP_THREADS__ macro", "__TIME__ macro", "__TIMESTAMP__ macro", "__VA_ARGS__ macro", "_VC_NODEFAULTLIB macro", "_WCHAR_T_DEFINED macro", "_WIN32 macro", "_WIN64 macro", "_WINRT_DLL macro", "__func__ identifier"] ms.assetid: 1cc5f70a-a225-469c-aed0-fe766238e23f -no-loc: [_ATL_VER, __ATOM__, __AVX__, __AVX2__, __AVX512BW__, __AVX512CD__, __AVX512DQ__, __AVX512F__, __AVX512VL__, _CHAR_UNSIGNED, __CLR_VER, _CONTROL_FLOW_GUARD, __COUNTER__, __cplusplus, __cplusplus_cli, __cplusplus_winrt, _CPPRTTI, _CPPUNWIND, __DATE__, _DEBUG, _DLL, __FILE__, __FUNCDNAME__, __FUNCSIG__, __FUNCTION__, _INTEGRAL_MAX_BITS, _ISO_VOLATILE, _KERNEL_MODE, __LINE__, _M_AMD64, _M_ARM, _M_ARM_ARMV7VE, _M_ARM_FP, _M_ARM64, _M_CEE, _M_CEE_PURE, _M_CEE_SAFE, _M_FP_EXCEPT, _M_FP_FAST, _M_FP_PRECISE, _M_FP_STRICT, _M_IX86, _M_IX86_FP, _M_X64, _MANAGED, _MFC_VER, _MSC_BUILD, _MSC_EXTENSIONS, _MSC_FULL_VER, _MSC_VER, _MSVC_LANG, __MSVC_RUNTIME_CHECKS, _MT, _NATIVE_WCHAR_T_DEFINED, _NO_SIZED_DEALLOCATION, _OPENMP, _PREFAST_, _RESUMABLE_FUNCTIONS_SUPPORTED, _RTC_CONVERSION_CHECKS_ENABLED, __STDC__, __STDC_HOSTED__, __STDC_NO_ATOMICS__, __STDC_NO_COMPLEX__, __STDC_NO_THREADS__, __STDC_NO_VLA__, __STDC_VERSION__, __STDCPP_THREADS__, __TIME__, __TIMESTAMP__, __VA_ARGS__, _VC_NODEFAULTLIB, _WCHAR_T_DEFINED, _WIN32, _WIN64, _WINRT_DLL, __func__] +no-loc: [_ATL_VER, __ATOM__, __AVX__, __AVX2__, __AVX512BW__, __AVX512CD__, __AVX512DQ__, __AVX512F__, __AVX512VL__, _CHAR_UNSIGNED, __CLR_VER, _CONTROL_FLOW_GUARD, __COUNTER__, __cplusplus, __cplusplus_cli, __cplusplus_winrt, _CPPRTTI, _CPPUNWIND, __DATE__, _DEBUG, _DLL, __FILE__, __FUNCDNAME__, __FUNCSIG__, __FUNCTION__, _INTEGRAL_MAX_BITS, _ISO_VOLATILE, _KERNEL_MODE, __LINE__, _M_AMD64, _M_ARM, _M_ARM_ARMV7VE, _M_ARM_FP, _M_ARM64, _M_CEE, _M_CEE_PURE, _M_CEE_SAFE, _M_FP_EXCEPT, _M_FP_FAST, _M_FP_PRECISE, _M_FP_STRICT, _M_IX86, _M_IX86_FP, _M_X64, _MANAGED, _MFC_VER, _MSC_BUILD, _MSC_EXTENSIONS, _MSC_FULL_VER, _MSC_VER, _MSVC_LANG, __MSVC_RUNTIME_CHECKS, _MT, _NATIVE_WCHAR_T_DEFINED, _NO_SIZED_DEALLOCATION, _OPENMP, _PREFAST_, _RESUMABLE_FUNCTIONS_SUPPORTED, _RTC_CONVERSION_CHECKS_ENABLED, __SANITIZE_ADDRESS__, __STDC__, __STDC_HOSTED__, __STDC_NO_ATOMICS__, __STDC_NO_COMPLEX__, __STDC_NO_THREADS__, __STDC_NO_VLA__, __STDC_VERSION__, __STDCPP_THREADS__, __TIME__, __TIMESTAMP__, __VA_ARGS__, _VC_NODEFAULTLIB, _WCHAR_T_DEFINED, _WIN32, _WIN64, _WINRT_DLL, __func__] --- # Predefined macros @@ -318,6 +318,8 @@ MSVC supports these additional predefined macros. - `_PREFAST_` Defined as 1 when the [`/analyze`](../build/reference/analyze-code-analysis.md) compiler option is set. Otherwise, undefined. +- `__SANITIZE_ADDRESS__` Available beginning with Visual Studio 2019 version 16.9. Defined as 1 when the [`/fsanitize=address`](../build/reference/fsanitize.md) compiler option is set. Otherwise, undefined. + - `__TIMESTAMP__` Defined as a string literal that contains the date and time of the last modification of the current source file, in the abbreviated, constant length form returned by the CRT [`asctime`](../c-runtime-library/reference/asctime-wasctime.md) function, for example, `Fri 19 Aug 13:32:58 2016`. This macro is always defined. - `_VC_NODEFAULTLIB` Defined as 1 when the [**`/Zl`** (Omit Default Library Name)](../build/reference/zl-omit-default-library-name.md) compiler option is set. Otherwise, undefined. diff --git a/docs/standard-library/chrono.md b/docs/standard-library/chrono.md index 1fff679d157..60f2d7923f0 100644 --- a/docs/standard-library/chrono.md +++ b/docs/standard-library/chrono.md @@ -82,18 +82,18 @@ Beginning in Visual Studio 2015, the implementation of `steady_clock` has change |Name|Description| |-|-| -|[`operator-`](chrono-operators.md#op_minus)|Subtract or negate various objects.| -|[`operator!=`](chrono-operators.md#op_neq)|Inequality operator that is used with various objects.| +|[`operator-`](chrono-operators.md#op_minus)|Subtract or negate various `` objects.| +|[`operator!=`](chrono-operators.md#op_neq)|Inequality operator that is used with various `` objects.| |[`operator modulo`](chrono-operators.md#op_modulo)|Operator for modulo operations on `duration` objects.| |[`operator*`](chrono-operators.md#op_star)|Multiplication operator for `duration` objects.| |[`operator/`](chrono-operators.md#op_div)|Division operator for `duration` objects.| |[`operator/`](chrono-operators.md#op_/)|Provides syntax to create calendar dates.| -|[`operator+`](chrono-operators.md#op_add)|Add to various objects.| -|[`operator<`](chrono-operators.md#op_lt)|Determines whether various objects are less than another.| -|[`operator<=`](chrono-operators.md#op_lt_eq)|Determines whether various objects are less than or equal to another.| -|[`operator==`](chrono-operators.md#op_eq_eq)|Determines whether various objects are equal to each other.| -|[`operator>`](chrono-operators.md#op_gt)|Determines whether various objects are greater than another.| -|[`operator>=`](chrono-operators.md#op_gt_eq)|Determines whether various objects are greater than or equal to another.| +|[`operator+`](chrono-operators.md#op_add)|Add to various `` objects.| +|[`operator<`](chrono-operators.md#op_lt)|Determines whether various `` objects are less than another.| +|[`operator<=`](chrono-operators.md#op_lt_eq)|Determines whether various `` objects are less than or equal to another.| +|[`operator==`](chrono-operators.md#op_eq_eq)|Determines whether various `` objects are equal to each other.| +|[`operator>`](chrono-operators.md#op_gt)|Determines whether various `` objects are greater than another.| +|[`operator>=`](chrono-operators.md#op_gt_eq)|Determines whether various `` objects are greater than or equal to another.| ## Typedefs (Predefined duration types)