Skip to content

Commit 75b5822

Browse files
Colin Robertsonv-shils
Colin Robertson
andauthored
Address vcsig issues in /std; also 3227 (#3662)
* Address vcsig issues in /std; also 3227 * Fix link * Updates per editor * Fixed typo in redirect file Co-authored-by: Shilpa Sharma <[email protected]>
1 parent 34a5899 commit 75b5822

14 files changed

+114
-116
lines changed

.openpublishing.redirection.json

+5
Original file line numberDiff line numberDiff line change
@@ -805,6 +805,11 @@
805805
"redirect_url": "/cpp/build-insights/reference/wpa-views",
806806
"redirect_document_id": false
807807
},
808+
{
809+
"source_path": "docs/c-language/generic_selection.md",
810+
"redirect_url": "/cpp/c-language/generic-selection",
811+
"redirect_document_id": false
812+
},
808813
{
809814
"source_path": "docs/c-language/operators-c.md",
810815
"redirect_url": "/cpp/c-language/lexical-grammar",

docs/build/reference/std-specify-language-standard-version.md

+29-34
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,12 @@ The **`/std`** options are available in Visual Studio 2017 and later. They're us
2222

2323
### C++ standards support
2424

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).
2626

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.
2829

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

3332
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:
3433

@@ -38,69 +37,65 @@ The following features remain enabled when the **`/std:c++14`** option is specif
3837
- [Attributes for namespaces and enumerators](https://wg21.link/n4266)
3938
- [u8 character literals](https://wg21.link/n4267)
4039

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.
4442

4543
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).
4644

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.
5047

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.
5249

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).
5451

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.
5653

5754
> [!NOTE]
5855
> 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.
5956
6057
### C standards support
6158

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.
6760

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.
6963

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.
7166

7267
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.
7368

7469
> [!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).
7671
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:
7873

79-
- [`_Pragma`](../../preprocessor/pragma-directives-and-the-pragma-keyword.md#the-_pragma-preprocessing-operator-c99-c11)
74+
- [`_Pragma`](../../preprocessor/pragma-directives-and-the-pragma-keyword.md#the-pragma-preprocessing-operator)
8075

81-
- **`restrict`**
76+
- [`restrict`](../../c-language/type-qualifiers.md#restrict)
8277

83-
- **`_Noreturn`** and \<stdnoreturn.h>
78+
- [`_Noreturn`](../../c-language/noreturn.md) and \<stdnoreturn.h>
8479

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

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

89-
- **`_Static_assert`**
84+
- [`_Static_assert`](../../c-language/static-assert-c.md)
9085

91-
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`.
9287

93-
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.
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.
9489

9590
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).
9691

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.
9893

9994
- `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).
10095

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.
10297

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.
10499

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

docs/c-language/c-keywords.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ The C language uses the following keywords:
5959
**`_Atomic`** <sup>2, b</sup>\
6060
**`_Bool`** <sup>1, a</sup>\
6161
**`_Complex`** <sup>1, b</sup>\
62-
**[`_Generic`](generic_selection.md)** <sup>2, a</sup>\
62+
**[`_Generic`](generic-selection.md)** <sup>2, a</sup>\
6363
**`_Imaginary`** <sup>1, b</sup>\
6464
**`_Noreturn`** <sup>2, a</sup>\
6565
**`_Static_assert`** <sup>2, a</sup>\

docs/c-language/c-primary-expressions.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ helpviewer_keywords: ["primary expressions"]
66
---
77
# C primary expressions
88

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.
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.
1010

1111
## Syntax
1212

@@ -23,5 +23,5 @@ Primary expressions are the building blocks of more complex expressions. They ma
2323

2424
## See also
2525

26-
[Generic selection](generic_selection.md)
26+
[Generic selection](generic-selection.md)
2727
[Operands and Expressions](../c-language/operands-and-expressions.md)

docs/c-language/generic_selection.md renamed to docs/c-language/generic-selection.md

+9-9
Original file line numberDiff line numberDiff line change
@@ -7,24 +7,24 @@ helpviewer_keywords: ["_Generic keyword [C]"]
77

88
# Generic selection (C11)
99

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, 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.
1111

1212
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"`.
1313

1414
## Syntax
1515

1616
*`generic-selection`*:\
17-
&nbsp;&nbsp;&nbsp;&nbsp;**`_Generic`** **(** *`assignment-expression`, `assoc-list`* **)**
17+
&emsp;**`_Generic`** **(** *`assignment-expression`, `assoc-list`* **)**
1818

1919
*`assoc-list`*:\
20-
&nbsp;&nbsp;&nbsp;&nbsp;*`association`*\
21-
&nbsp;&nbsp;&nbsp;&nbsp;*`assoc-list`, `association`*
20+
&emsp;*`association`*\
21+
&emsp;*`assoc-list`, `association`*
2222

2323
*`association`*:\
24-
&nbsp;&nbsp;&nbsp;&nbsp;*`type-name`* : *`assignment-expression`*\
25-
&nbsp;&nbsp;&nbsp;&nbsp;**`default`** : *`assignment-expression`*
24+
&emsp;*`type-name`* : *`assignment-expression`*\
25+
&emsp;**`default`** : *`assignment-expression`*
2626

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

2929
When the type of the controlling expression is determined, `const`, `volatile`, and `restrict` are removed before matching against *`assoc-list`*.
3030

@@ -38,7 +38,7 @@ Entries in the `assoc-list` that aren't chosen aren't evaluated.
3838

3939
## Example
4040

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

4343
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:
4444

@@ -78,5 +78,5 @@ Windows SDK 10.0.20348.0 (version 2104) or later. See [Windows 10 SDK](https://d
7878

7979
## See also
8080

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)\
8282
[Type-generic math](../c-runtime-library/tgmath.md)

docs/c-language/noreturn.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ helpviewer_keywords: ["keywords [C]"]
1010

1111
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.
1212

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.
1414

1515
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.
1616

docs/c-language/toc.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@
273273
- name: Expressions in parentheses
274274
href: ../c-language/expressions-in-parentheses.md
275275
- name: Generic selection (C11)
276-
href: ../c-language/generic_selection.md
276+
href: ../c-language/generic-selection.md
277277
- name: L-value and r-value expressions
278278
href: ../c-language/l-value-and-r-value-expressions.md
279279
- name: C constant expressions

docs/c-language/type-qualifiers.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ If **`volatile`** is used alone, **`int`** is assumed. The **`volatile`** type s
5656
5757
## `restrict`
5858
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.
6060
6161
**`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)
6262

0 commit comments

Comments
 (0)