Skip to content

Repo sync for protected branch #5166

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 30 commits into from
Jan 30, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
c682470
start
TylerMSFT Jan 24, 2025
40c1f45
Merge branch 'main' of https://github.com/MicrosoftDocs/cpp-docs-pr i…
TylerMSFT Jan 27, 2025
a00c37e
draft new switch
TylerMSFT Jan 29, 2025
65f3f97
formatting
TylerMSFT Jan 29, 2025
ef045db
feedback
TylerMSFT Jan 29, 2025
4130577
Update docs/build/reference/std-specify-language-standard-version.md
TylerMSFT Jan 29, 2025
679998e
Merge branch 'std23' of https://github.com/TylerMSFT/cpp-docs-pr into…
TylerMSFT Jan 29, 2025
9e5efac
Update docs/build/reference/std-specify-language-standard-version.md
TylerMSFT Jan 29, 2025
591467b
Merge branch 'std23' of https://github.com/TylerMSFT/cpp-docs-pr into…
TylerMSFT Jan 29, 2025
8b1e86c
feedback
TylerMSFT Jan 29, 2025
a427fd3
feedback
TylerMSFT Jan 29, 2025
318e7de
add more version info
TylerMSFT Jan 29, 2025
bdfb3a6
Update binary-compat-2015-2017.md
PoulChapman Jan 29, 2025
0845f08
change version
TylerMSFT Jan 29, 2025
661e35f
Update latest-supported-vc-redist.md
PoulChapman Jan 29, 2025
1fa94ee
Update redist-version-auditing.md
PoulChapman Jan 29, 2025
1de4603
Merge pull request #1 from PoulChapman/patch-3
PoulChapman Jan 29, 2025
e697920
Merge pull request #2 from PoulChapman/patch-2
PoulChapman Jan 29, 2025
ac5d43e
Merge pull request #3 from PoulChapman/patch-1
PoulChapman Jan 29, 2025
8e99339
fix see also link section
PoulChapman Jan 29, 2025
1fbd034
Fix broken links in redist-version-auditing.md
PoulChapman Jan 29, 2025
9989e16
Remove trailing backslash in markdown link
PoulChapman Jan 29, 2025
f5b0e57
Remove trailing backslash in markdown link
PoulChapman Jan 30, 2025
3a5cd65
Merge pull request #5750 from TylerMSFT/std23
AnnaMHuff Jan 30, 2025
71be91a
Fix broken link in binary compatibility doc
PoulChapman Jan 30, 2025
a3e98e7
Fix broken links in documentation
PoulChapman Jan 30, 2025
24fe313
Fix link extension in documentation
PoulChapman Jan 30, 2025
bf918d5
Merge pull request #5756 from PoulChapman/main
prmerger-automator[bot] Jan 30, 2025
586dfb7
Merge pull request #5755 from MicrosoftDocs/FromPublicMasterBranch
v-alje Jan 30, 2025
a1e91a7
Merge pull request #5757 from MicrosoftDocs/main
v-alje Jan 30, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 38 additions & 33 deletions docs/build/reference/std-specify-language-standard-version.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
---
title: "/std (Specify Language Standard Version)"
description: "The MSVC compiler option /std specifies the C or C++ language standard supported by the compiler."
ms.date: 4/9/2023
f1_keywords: ["/std", "-std", "/std:c++14", "/std:c++17", "/std:c++20", "/std:c11", "/std:c17", "/std:clatest", "VC.Project.VCCLCompilerTool.CppLanguageStandard"]
ms.date: 1/29/2025
f1_keywords: ["/std", "-std", "/std:c++14", "/std:c++17", "/std:c++20", "/std:c++23preview", "/std:c++latest", "/std:c11", "/std:c17", "/std:clatest", "VC.Project.VCCLCompilerTool.CppLanguageStandard"]
---
# `/std` (Specify Language Standard Version)

Expand All @@ -13,6 +13,7 @@ Enable supported C and C++ language features from the specified version of the C
> **`/std:c++14`**\
> **`/std:c++17`**\
> **`/std:c++20`**\
> **`/std:c++23preview`**\
> **`/std:c++latest`**\
> **`/std:c11`**\
> **`/std:c17`**\
Expand All @@ -24,63 +25,73 @@ The **`/std`** options are available in Visual Studio 2017 and later. They're us

The Microsoft C++ compiler in Visual Studio 2017 and later versions doesn't support C++ standards modes earlier than C++14 (**`/std:c++14`**). Such support isn't planned. As an imperfect workaround, it's possible to use older Visual C++ compiler toolsets that didn't implement features from later standards. For more information on how to install and use older compiler toolsets in Visual Studio, see [Use native multi-targeting in Visual Studio to build old projects](../../porting/use-native-multi-targeting.md).

### C++ standards support
## C++ standards support

The **`/std`** option in effect during a C++ compilation can be detected by use of the [`_MSVC_LANG`](../../preprocessor/predefined-macros.md) preprocessor macro. For more information, see [Preprocessor Macros](../../preprocessor/predefined-macros.md).
Detect whether the **`/std`** option is in effect during a C++ compilation with the [`_MSVC_LANG`](../../preprocessor/predefined-macros.md) preprocessor macro. For more information, see [Preprocessor Macros](../../preprocessor/predefined-macros.md).

> [!IMPORTANT]
> Because some existing code depends on the value of the macro `__cplusplus` being `199711L`, the MSVC compiler doesn't change the value of this macro unless you explicitly opt in by setting [`/Zc:__cplusplus`](zc-cplusplus.md). Specify `/Zc:__cplusplus` and the **`/std`** option to set `__cplusplus` to the appropriate value.

**`/std:c++14`**\
The **`/std:c++14`** option enables C++14 standard-specific features implemented by the MSVC compiler. This option is the default for code compiled as C++. It's available starting in Visual Studio 2015 Update 3.
### `/std:c++14`

Enables C++14 standard-specific features implemented by the MSVC compiler. This option is the default for code compiled as C++. It's available starting in Visual Studio 2015 Update 3.

This option disables compiler and standard library support for features that are changed or new in more recent versions of the language standard. However, it doesn't disable some C++17 features already implemented in previous releases of the MSVC compiler. For more information, see [Microsoft C/C++ language conformance](../../overview/visual-cpp-language-conformance.md). The tables indicate which C++17 features are enabled when you specify **`/std:c++14`**.

The following features remain enabled when the **`/std:c++14`** option is specified to avoid breaking changes for users who have already taken dependencies on the features available in or before Visual Studio 2015 Update 2:
The following features remain enabled when the **`/std:c++14`** option is specified to avoid breaking changes for users who took dependencies on features available in or before Visual Studio 2015 Update 2:

- [Rules for `auto` with braced-init-lists](https://wg21.link/n3922)
- [`typename` in template template-parameters](https://wg21.link/n4051)
- [Removing trigraphs](https://wg21.link/n4086)
- [Attributes for namespaces and enumerators](https://wg21.link/n4266)
- [u8 character literals](https://wg21.link/n4267)

**`/std:c++17`**\
The **`/std:c++17`** option enables C++17 standard-specific features and behavior. It enables the full set of C++17 features implemented by the MSVC compiler. This option disables compiler and standard library support for features that are new or changed after C++17. It specifically disables post-C++17 changes in the C++ Standard and versions of the Working Draft. It doesn't disable retroactive defect updates of the C++ Standard. This option is available starting in Visual Studio 2017 version 15.3.
### `/std:c++17`

Enables C++17 standard-specific features and behavior. It enables the full set of C++17 features implemented by the MSVC compiler. This option disables compiler and standard library support for features that are new or changed after C++17. It specifically disables post-C++17 changes in the C++ Standard and versions of the Working Draft. It doesn't disable retroactive defect updates of the C++ Standard. This option is available starting in Visual Studio 2017 version 15.3.

Depending on the MSVC compiler version or update level, C++17 features may not be fully implemented or fully conforming when you specify the **`/std:c++17`** option. For an overview of C++ language conformance in Visual C++ by release version, see [Microsoft C/C++ language conformance](../../overview/visual-cpp-language-conformance.md).

**`/std:c++20`**\
The **`/std:c++20`** option enables C++20 standard-specific features and behavior. Available starting in Visual Studio 2019 version 16.11, it enables the full set of C++20 features implemented by the MSVC compiler. Note that Visual Studio 2022 version 17.0 does not support `std::format`, the C++20 `<chrono>` formatting extensions, and the range factories and range adaptors from `<ranges>` under **`/std:c++20`** due to late-breaking changes in those features immediately after publication of the Standard.
### `/std:c++20`

Enables C++20 standard-specific features and behavior.

Enables the standard conformance mode provided by [**`/permissive-`**](./permissive-standards-conformance.md) unless explicitly overridden with **`/permissive`**.

The **`/std:c++20`** option disables compiler and standard library support for features that are new or changed after C++20. It specifically disables post-C++20 changes in the C++ Standard and versions of the Working Draft. It doesn't disable retroactive defect updates of the C++ Standard.
### `/std:c++23preview`

The **`/std:c++20`** option enables the standard conformance mode provided by [**`/permissive-`**](./permissive-standards-conformance.md) unless explicitly overriden with **`/permissive`**.
Enables preview C++23 standard-specific features and behavior. Available starting in Visual Studio 2022 version 17.13 Preview 4. Preview features may change and may not be ABI compatible across releases.

**`/std:c++latest`**\
The **`/std:c++latest`** option enables all currently implemented compiler and standard library features proposed for the next draft standard, as well as some in-progress and experimental features. This option is available starting in Visual Studio 2015 Update 3.
This switch will be removed when the `/std:c++23` switch is implemented--at which point C++23 features will be fully implemented and ABI stable. If in project properties **C/C++** > **Language** you specify **Preview - ISO C++ 23 Standard (/std:c++preview)**, it will automatically change to mean `/std:c++23` once the new switch is implemented.

Depending on the MSVC compiler version or update level, C++17, C++20, or proposed C++23 features may not be fully implemented or fully conforming when you specify the **`/std:c++latest`** option. We recommend you use the latest version of Visual Studio for maximum standards conformance. For an overview of C++ language and library conformance in Visual C++ by release version, see [Microsoft C/C++ language conformance](../../overview/visual-cpp-language-conformance.md).
This switch differs from `/std:c++latest` in that it only enables features that are part of the C++23 standard. It doesn't enable experimental or in-progress features.

In versions of Visual Studio 2019 before version 16.11, **`/std:c++latest`** is required to enable all the compiler and standard library features of C++20.
### `/std:c++latest`

Since Visual Studio 2019 version 16.8, the **`/std:c++latest`** option has enabled the standard conformance mode provided by [**`/permissive-`**](./permissive-standards-conformance.md) unless explicitly overriden with **`/permissive`**.
Enables all currently implemented compiler and standard library features proposed in the next ISO C++ working draft, as well as some in-progress and experimental features. This option is available starting with Visual Studio 2015 Update 3.

Depending on the MSVC compiler version or update level, features from published C++ standards or proposed features in the current C++ working draft, may not be fully implemented or fully conforming when you specify the **`/std:c++latest`** option. We recommend you use the latest version of Visual Studio for maximum standards conformance. For an overview of C++ language and library conformance in Visual C++ by release version, see [Microsoft C/C++ language conformance](../../overview/visual-cpp-language-conformance.md).

Since Visual Studio 2019 version 16.8, the **`/std:c++latest`** option has enabled the standard conformance mode provided by [**`/permissive-`**](./permissive-standards-conformance.md) unless explicitly overridden with **`/permissive`**.

For a list of supported language and library features, see [What's New for C++ in Visual Studio](../../overview/what-s-new-for-visual-cpp-in-visual-studio.md).

The **`/std:c++latest`** option doesn't enable features guarded by the **`/experimental`** switch, but may be required to enable them.

> [!NOTE]
> The compiler and library features enabled by **`/std:c++latest`** may appear in a future C++ standard. Features that have not been approved are subject to breaking changes or removal without notice and are provided on an as-is basis.
> The compiler and library features enabled by **`/std:c++latest`** may appear in a future C++ standard. Features that haven't been approved are subject to breaking changes or removal without notice and are provided on an as-is basis.

### C standards support
## C standards support

You can invoke the Microsoft C compiler by using the [`/TC` or `/Tc`](tc-tp-tc-tp-specify-source-file-type.md) compiler option. It's used by default for code that has a *`.c`* file extension, unless overridden by a **`/TP`** or **`/Tp`** option. The default C compiler (that is, the compiler when **`/std:c11`** or **`/std:c17`** isn't specified) implements ANSI C89, but includes several Microsoft extensions, some of which are part of ISO C99. Some Microsoft extensions to C89 can be disabled by using the [`/Za`](za-ze-disable-language-extensions.md) compiler option, but others remain in effect. It isn't possible to specify strict C89 conformance. The compiler doesn't implement several required features of C99, so it isn't possible to specify C99 conformance, either.

**`/std:c11`**\
The **`/std:c11`** option enables ISO C11 conformance. It's available starting in Visual Studio 2019 version 16.8.
### `/std:c11`

Enables ISO C11 conformance. It's available starting in Visual Studio 2019 version 16.8.

### `/std:c17`

**`/std:c17`**\
The **`/std:c17`** option enables ISO C17 conformance. It's available starting in Visual Studio 2019 version 16.8.
Enables ISO C17 conformance. It's available starting in Visual Studio 2019 version 16.8.

Because the new preprocessor is needed to support these standards, the **`/std:c11`** and **`/std:c17`** compiler options set the [`/Zc:preprocessor`](zc-preprocessor.md) option automatically. If you want to use the traditional (legacy) preprocessor for C11 or C17, you must set the **`/Zc:preprocessor-`** compiler option explicitly. Setting the **`/Zc:preprocessor-`** option may lead to unexpected behavior, and isn't recommended.

Expand All @@ -90,15 +101,10 @@ Because the new preprocessor is needed to support these standards, the **`/std:c
When you specify **`/std:c11`** or **`/std:c17`**, MSVC supports all the features of C11 and C17 required by the standards. The **`/std:c11`** and **`/std:c17`** compiler options enable support for these functionalities:

- [`_Pragma`](../../preprocessor/pragma-directives-and-the-pragma-keyword.md#the-pragma-preprocessing-operator)

- [`restrict`](../../c-language/type-qualifiers.md#restrict)

- [`_Noreturn`](../../c-language/noreturn.md) and \<stdnoreturn.h>

- [`_Alignas`, `_Alignof`](../../c-language/alignment-c.md) and \<stdalign.h>

- [`_Generic`](../../c-language/generic-selection.md) and \<tgmath.h>

- [`_Static_assert`](../../c-language/static-assert-c.md)

The IDE uses C settings for IntelliSense and code highlighting when your source files have a *`.c`* file extension, or when you specify the [`/TC` or `/Tc`](tc-tp-tc-tp-specify-source-file-type.md) compiler option. Currently, IntelliSense in C highlights keywords `_Alignas`, `_Alignof`, `_Noreturn`, and `_Static_assert`, but not the equivalent macros defined in the standard headers: `alignas`, `alignof`, `noreturn`, and `static_assert`.
Expand All @@ -115,17 +121,16 @@ The compiler doesn't support most optional features of ISO C11. Several of these

- Variable length array (VLA) support isn't planned. VLAs provide attack vectors comparable to [`gets`](../../c-runtime-library/gets-getws.md), which is deprecated and planned for removal.

**`/std:clatest`**\
The **`/std:clatest`** option behaves like the `/std:c++latest` switch for the C++ compiler. The switch enables all currently implemented compiler and standard library features proposed for the next draft C standard, as well as some in-progress and experimental features.
### `/std:clatest`

The **`/std:clatest`** option behaves like the `/std:c++latest` switch for the C++ compiler. The switch enables all currently implemented compiler and standard library features proposed in the next draft C standard, as well as some in-progress and experimental features.

For more information, see the C Standard library features section of [Microsoft C/C++ language conformance](../../overview/visual-cpp-language-conformance.md).

### To set this compiler option in the Visual Studio development environment

1. Open the project's **Property Pages** dialog box. For more information, see [Set C++ compiler and build properties in Visual Studio](../working-with-project-properties.md).

1. Select the **Configuration Properties** > **C/C++** > **Language** property page.

1. In **C++ Language Standard** (or for C, **C Language Standard**), choose the language standard to support from the dropdown control, then choose **OK** or **Apply** to save your changes.

## See also
Expand Down
4 changes: 3 additions & 1 deletion docs/porting/binary-compat-2015-2017.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,6 @@ This error is by design. We recommend you keep the newest version installed. Mak
## See also

[Visual C++ change history](../porting/visual-cpp-change-history-2003-2015.md)\
[The latest supported Visual C++ Redistributable downloads](../windows/latest-supported-vc-redist.md)
[The latest supported Visual C++ Redistributable downloads](../windows/latest-supported-vc-redist.md)\
[How to audit Visual C++ Runtime version usage](../windows/redist-version-auditing.md)\
[Lifecycle FAQ - Visual C++ Redistributable and runtime libraries](/lifecycle/faq/visual-c-faq)
10 changes: 8 additions & 2 deletions docs/windows/latest-supported-vc-redist.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,13 @@ Download Redistributable files for other languages and architectures from:

- Redistributable files for X86, X64, and IA64 architectures are available from [Microsoft Visual C++ 2005 Service Pack 1 Redistributable Package MFC Security Update](https://www.microsoft.com/download/details.aspx?id=26347).

## Release notes
## See Also

- [C++ binary compatibility between Visual Studio versions](../porting/binary-compat-2015-2017.md)
- [How to audit Visual C++ Runtime version usage](redist-version-auditing.md)
- [Lifecycle FAQ - Visual C++ Redistributable and runtime libraries](/lifecycle/faq/visual-c-faq)

**Release notes**

- [Visual Studio 2022 release notes](/visualstudio/releases/2022/release-notes)
- [What's new for C++ in Visual Studio](../overview//what-s-new-for-visual-cpp-in-visual-studio.md)
Expand All @@ -125,7 +131,7 @@ Download Redistributable files for other languages and architectures from:
- [A year of C++ improvements](https://devblogs.microsoft.com/cppblog/a-year-of-cpp-improvements-in-visual-studio-vs-code-and-vcpkg)
- [Microsoft Visual C++ compiler versioning](../overview/compiler-versions.md)

## C++ conformance notes
**C++ conformance notes**

- [C++ conformance improvements in Visual Studio](../overview/cpp-conformance-improvements.md)
- [C++ conformance improvements in Visual Studio 2019](../overview/cpp-conformance-improvements-2019.md)
Expand Down
3 changes: 2 additions & 1 deletion docs/windows/redist-version-auditing.md
Original file line number Diff line number Diff line change
Expand Up @@ -192,4 +192,5 @@ Here is where each version of the VC Runtime is installed:

[Redistributing Visual C++ Files](redistributing-visual-cpp-files.md)\
[The latest supported Visual C++ downloads](latest-supported-vc-redist.md)\
[Lifecycle FAQ - Visual C++ Redistributable and runtime libraries](/lifecycle/faq/visual-c-faq)
[Lifecycle FAQ - Visual C++ Redistributable and runtime libraries](/lifecycle/faq/visual-c-faq)\
[C++ binary compatibility between Visual Studio versions](../porting/binary-compat-2015-2017.md)