You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/build/reference/std-specify-language-standard-version.md
+29-34
Original file line number
Diff line number
Diff line change
@@ -22,13 +22,12 @@ The **`/std`** options are available in Visual Studio 2017 and later. They're us
22
22
23
23
### C++ standards support
24
24
25
-
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).
25
+
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).
26
26
27
-
**`/std:c++14`**
27
+
**`/std:c++14`**\
28
+
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.
28
29
29
-
Enables C++14 standard-specific features implemented by the MSVC compiler. This option is the default for code compiled as C++. Available starting with Visual Studio 2015 Update 3. Enables C++14 standard-specific features implemented by the MSVC compiler.
30
-
31
-
This option disables compiler and standard library support for features that are changed or new in more recent versions of the language standard. 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). It indicates which C++14 and C++17 features are enabled when you specify **`/std:c++14`**.
30
+
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`**.
32
31
33
32
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:
34
33
@@ -38,69 +37,65 @@ The following features remain enabled when the **`/std:c++14`** option is specif
38
37
-[Attributes for namespaces and enumerators](https://wg21.link/n4266)
39
38
-[u8 character literals](https://wg21.link/n4267)
40
39
41
-
**`/std:c++17`**
42
-
43
-
Enable C++17 standard-specific features and behavior. 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. That includes post-C++17 changes in versions of the Working Draft and defect updates of the C++ Standard. Available starting in Visual Studio version 15.3
40
+
**`/std:c++17`**\
41
+
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 does not disable retroactive defect updates of the C++ Standard. This option is available starting in Visual Studio 2017 version 15.3.
44
42
45
43
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`** options. 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).
46
44
47
-
**`/std:c++latest`**
48
-
49
-
Enable all currently implemented compiler and standard library features proposed for the next draft standard. Available starting with Visual Studio 2015 Update 3
45
+
**`/std:c++latest`**\
46
+
The **`/std:c++latest`** option enables all currently implemented compiler and standard library features proposed for the next draft standard, as well as some experimental features. This option is available starting in Visual Studio 2015 Update 3.
50
47
51
-
Enables the post-C++17 language and library features currently implemented in the compiler and libraries. These features may include changes to the latest Working Draft standard, defect updates, and experimental proposals for the standard.
48
+
As of Visual Studio 2019 version 16.10, **`/std:c++latest`** is required to enable all the compiler and standard library features of C++20. There will be a **`/std:c++20`** option that does not include later proposed or experimental features in a future version of Visual Studio.
52
49
53
-
For a list of supported language and library features, see [What's New for Visual C++](../../overview/what-s-new-for-visual-cpp-in-visual-studio.md).
50
+
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).
54
51
55
-
This option doesn't enable features guarded by the **`/experimental`** switch, but may be required to enable them.
52
+
The **`/std:c++latest`** option doesn't enable features guarded by the **`/experimental`** switch, but may be required to enable them.
56
53
57
54
> [!NOTE]
58
55
> The compiler and library features enabled by **`/std:c++latest`** may appear in a future C++ standard, as well as approved C++20 features. Features that have not been approved are subject to breaking changes or removal without notice and are provided on an as-is basis.
59
56
60
57
### C standards support
61
58
62
-
By default, when code is compiled as C, the MSVC compiler doesn't conform to a particular C standard. It implements ANSI C89 with several Microsoft extensions, some of which are part of ISO C99. Some Microsoft extensions 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.
63
-
64
-
**`/std:c11`**
65
-
66
-
Enable ISO C11 conformance. Available starting in Visual Studio 2019 version 16.8.
59
+
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.
67
60
68
-
**`/std:c17`**
61
+
**`/std:c11`**\
62
+
The **`/std:c11`** option enables ISO C11 conformance. It's available starting in Visual Studio 2019 version 16.8.
69
63
70
-
Enable ISO C17 conformance. Available starting in Visual Studio 2019 version 16.8.
64
+
**`/std:c17`**\
65
+
The **`/std:c17`** option enables ISO C17 conformance. It's available starting in Visual Studio 2019 version 16.8.
71
66
72
67
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.
73
68
74
69
> [!NOTE]
75
-
> At the time of release, the Windows SDK and UCRT libraries installed by Visual Studio don't support C11 and C17 code ywt. An updated version of the Windows SDK and UCRT is required. For more information and installation instructions, see [Install C11 and C17 support in Visual Studio](../../overview/install-c17-support.md).
70
+
> At the time of release and through Visual Studio 2019 version 16.10, the Windows SDK and UCRT libraries installed by Visual Studio don't yet support C11 and C17 code. An updated version of the Windows SDK and UCRT is required. For more information and installation instructions, see [Install C11 and C17 support in Visual Studio](../../overview/install-c17-support.md).
76
71
77
-
When you specify **`/std:c11`** or **`/std:c17`**, MSVC supports all the features of C11 and C17 required by the standard. (Certain optional features aren't supported.) The compiler options enable support for these functionalities:
72
+
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:
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`](tc-tp-tc-tp-specify-source-file-type.md) compiler option. Currently, IntelliSense highlighting is only available for keywords, and not the macros introduced by the standard headers.
86
+
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`.
92
87
93
-
Since C17 is largely a bugfix release of ISO C11, MSVC support for C11 already includes all the relevant defect reports. There are no differences between the C11 and C17 versions except for the `__STDC_VERSION__` macro. It expands to `201112L` for C11, and `201710L` for C17.
88
+
Since C17 is largely a bug-fix release of ISO C11, MSVC support for C11 already includes all the relevant defect reports. There are no differences between the C11 and C17 versions except for the `__STDC_VERSION__` macro. It expands to `201112L` for C11, and `201710L` for C17.
94
89
95
90
The compiler doesn't support most optional features of ISO C11. Several of these optional features of C11 were required features of C99 that MSVC hasn't implemented for architectural reasons. You can use the feature test macros such as `__STDC_NO_VLA__` to detect compiler support levels for individual features. For more information about C-specific predefined macros, see [Predefined macros](../../preprocessor/predefined-macros.md).
96
91
97
-
- There's no conforming multithreading, atomic, or complex number support in the Visual Studio 2019 version 16.8 release.
92
+
- There's no conforming multithreading, atomic, or complex number support.
98
93
99
94
-`aligned_alloc` support is missing, because of the Windows heap implementation. The alternative is to use [`_aligned_malloc`](../../c-runtime-library/reference/aligned-malloc.md).
100
95
101
-
- DR 400 support is currently unimplemented for `realloc`, because this change would break the ABI.
96
+
-[DR 400](http://www.open-std.org/jtc1/sc22/wg14/www/docs/summary.htm#dr_400) support is currently unimplemented for `realloc`, because this change would break the ABI.
102
97
103
-
- Variable length array (VLA) support isn't planned. VLAs provide attack vectors comparable to `gets()`, which is deprecated and planned for removal.
98
+
- 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.
104
99
105
100
For more information, see the C Standard library features section of [Microsoft C/C++ language conformance](../../overview/visual-cpp-language-conformance.md).
Primary expressions are the building blocks of more complex expressions. They may be constants, identifiers, a [Generic selection](generic_selection.md), or an expression in parentheses.
9
+
Primary expressions are the building blocks of more complex expressions. They may be constants, identifiers, a [Generic selection](generic-selection.md), or an expression in parentheses.
10
10
11
11
## Syntax
12
12
@@ -23,5 +23,5 @@ Primary expressions are the building blocks of more complex expressions. They ma
23
23
24
24
## See also
25
25
26
-
[Generic selection](generic_selection.md)
26
+
[Generic selection](generic-selection.md)
27
27
[Operands and Expressions](../c-language/operands-and-expressions.md)
Use the **`_Generic`** keyword to write code that selects an expression at compile time based on the type of the argument. It's similar to overloading in C++ where the type of the argument selects which function to call, except that the type of the argument selects which expression to evaluate.
10
+
Use the **`_Generic`** keyword to write code that selects an expression at compile time based on the type of the argument. It's similar to overloading in C++ where the type of the argument selects which function to call. In this case, the type of the argument selects which expression to evaluate.
11
11
12
12
For example, the expression `_Generic(42, int: "integer", char: "character", default: "unknown");` evaluates the type of `42` and looks for the matching type, `int`, in the list. It finds it and returns `"integer"`.
The first *`assignment-expression`* is called the controlling expression. The type of the controlling expression is determined at compile time and matched against the *`assoc-list`* to find which expression to evaluate and return. The controlling expression is not evaluated. For example, `_Generic(intFunc(), int: "integer", default: "error");` doesn't result in a call at runtime to `intFunc()`.
27
+
The first *`assignment-expression`* is called the controlling expression. The type of the controlling expression is determined at compile time and matched against the *`assoc-list`* to find which expression to evaluate and return. The controlling expression isn't evaluated. For example, `_Generic(intFunc(), int: "integer", default: "error");` doesn't result in a call at runtime to `intFunc`.
28
28
29
29
When the type of the controlling expression is determined, `const`, `volatile`, and `restrict` are removed before matching against *`assoc-list`*.
30
30
@@ -38,7 +38,7 @@ Entries in the `assoc-list` that aren't chosen aren't evaluated.
38
38
39
39
## Example
40
40
41
-
One way to use **`_Generic`** is in a macro. The <tgmath.h> header file uses **_Generic** to call the right math function depending on the type of argument. For example, the macro for `cos()` maps a call with a float to `cosf()`, while mapping a call with a complex double to `ccos()`.
41
+
One way to use **`_Generic`** is in a macro. The \<tgmath.h> header file uses **`_Generic`** to call the right math function depending on the type of argument. For example, the macro for `cos` maps a call with a float to `cosf`, while mapping a call with a complex double to `ccos`.
42
42
43
43
The following example shows how to write a macro that identifies the type of the argument you pass to it. It produces `"unknown"` if no entry in the *`assoc-list`* matches the controlling expression:
44
44
@@ -78,5 +78,5 @@ Windows SDK 10.0.20348.0 (version 2104) or later. See [Windows 10 SDK](https://d
78
78
79
79
## See also
80
80
81
-
[`/std` (Specify Language Standard Version)](../build/reference/std-specify-language-standard-version.md)\
81
+
[`/std` (Specify language standard version)](../build/reference/std-specify-language-standard-version.md)\
The `_Noreturn` keyword was introduced in C11. It tells the compiler that the function it's applied to doesn't return to the caller. The compiler knows that the code following a call to a `_Noreturn` function is unreachable. An example of a function that doesn't return is [abort](../c-runtime-library/reference/abort.md). If there's a possibility for control flow to return to the caller, the function must not have the `_Noreturn` attribute.
12
12
13
-
The keyword is typically used through the convenience macro, `noreturn`, provided in <stdnoreturn.h>, which maps to the `_Noreturn` keyword.
13
+
The keyword is typically used through the convenience macro, `noreturn`, provided in \<stdnoreturn.h>, which maps to the `_Noreturn` keyword.
14
14
15
15
The primary benefits for using `_Noreturn` (or the equivalent `noreturn`) are making the intention of the function clear in the code for future readers, and detecting unintentionally unreachable code.
Copy file name to clipboardExpand all lines: docs/c-language/type-qualifiers.md
+1-1
Original file line number
Diff line number
Diff line change
@@ -56,7 +56,7 @@ If **`volatile`** is used alone, **`int`** is assumed. The **`volatile`** type s
56
56
57
57
## `restrict`
58
58
59
-
The **`restrict`** type qualifier, introduced in C99, can be applied to pointer declarations. It qualifies the pointer, not what it points at.
59
+
The **`restrict`** type qualifier, introduced in C99 and available in [`/std:c11` or `/std:c17`](../build/reference/std-specify-language-standard-version.md) mode, can be applied to pointer declarations. It qualifies the pointer, not what it points at.
60
60
61
61
**`restrict`** is an optimization hint to the compiler that no other pointer in the current scope refers to the same memory location. That is, only the pointer or a value derived from it (such as pointer + 1) is used to access the object during the lifetime of the pointer. This helps the compiler produce more optimized code. C++ has an equivalent mechanism, [`__restrict`](../cpp/extension-restrict.md)
0 commit comments