Skip to content

Commit a7f4f49

Browse files
author
Colin Robertson
authored
C11/C17 /std support and SDK install docs (MicrosoftDocs#3140)
* C11/C17 /std support and SDK install docs * Acrolinx pass * touch * Fix typos * Add predefined macros for C11/C17 * Expand on supported standards * Add keywords * fix table issues * add qualification * Updates per review * Add message text * en-us locale is required!
1 parent a8c6859 commit a7f4f49

File tree

7 files changed

+232
-68
lines changed

7 files changed

+232
-68
lines changed

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

Lines changed: 50 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,29 @@
11
---
22
title: "/std (Specify Language Standard Version)"
3-
ms.date: "06/04/2020"
4-
f1_keywords: ["/std", "-std", "VC.Project.VCCLCompilerTool.CppLanguageStandard"]
3+
description: "The MSVC compiler option /std specifies the C or C++ language standard supported by the compiler."
4+
ms.date: 09/11/2020
5+
f1_keywords: ["/std", "-std", "/std:c++14", "/std:c++17", "/std:c11", "/std:c17", "VC.Project.VCCLCompilerTool.CppLanguageStandard"]
56
ms.assetid: 0acb74ba-1aa8-4c05-b96c-682988dc19bd
67
---
78
# `/std` (Specify Language Standard Version)
89

9-
Enable supported C++ language features from the specified version of the C++ language standard.
10+
Enable supported C and C++ language features from the specified version of the C or C++ language standard.
1011

1112
## Syntax
1213

1314
> **`/std:c++14`**\
1415
> **`/std:c++17`**\
15-
> **`/std:c++latest`**
16+
> **`/std:c++latest`**\
17+
> **`/std:c11`**\
18+
> **`/std:c17`**
1619
1720
## Remarks
1821

19-
The **`/std`** option is available in Visual Studio 2017 and later. It's used to control the version-specific ISO C++ programming language standard features enabled during compilation of your code. This option allows you to disable support for certain new language and library features: ones that may break your existing code that conforms to a particular version of the language standard. By default, **`/std:c++14`** is specified, which disables language and standard library features found in later versions of the C++ language standard. Use **`/std:c++17`** to enable C++17 standard-specific features and behavior. To explicitly enable the currently implemented compiler and standard library features proposed for the next draft standard, use **`/std:c++latest`**. All C++20 features require **`/std:c++latest`**; when the implementation is complete, a new **`/std:c++20`** option will be enabled.
22+
The **`/std`** option is available in Visual Studio 2017 and later. It's used to control the version-specific ISO C or C++ programming language standard features enabled during compilation of your code. This option allows you to disable support for certain new language and library features: ones that may break your existing code that conforms to a particular version of the language standard.
23+
24+
### C++ standards support
25+
26+
By default, **`/std:c++14`** is specified, which disables language and standard library features found in later versions of the C++ language standard. Use **`/std:c++17`** to enable C++17 standard-specific features and behavior. To explicitly enable the currently implemented compiler and standard library features proposed for the next draft standard, use **`/std:c++latest`**. All C++20 features require **`/std:c++latest`**; when the implementation is complete, a new **`/std:c++20`** option will be enabled.
2027

2128
The default **`/std:c++14`** option enables the set of C++14 features implemented by the MSVC compiler. 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. To avoid breaking changes for users who have already taken dependencies on the features available in or before Visual Studio 2015 Update 2, these features remain enabled when the **`/std:c++14`** option is specified:
2229

@@ -46,13 +53,50 @@ The **`/std:c++14`** and **`/std:c++latest`** options are available beginning in
4653
> [!NOTE]
4754
> 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++ language conformance table](../../overview/visual-cpp-language-conformance.md).
4855
56+
### C standards support
57+
58+
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.
59+
60+
Starting in Visual Studio 2019 version 16.8, you may specify **`/std:c11`** or **`/std:c17`** for code compiled as C. These options specify conformance modes that correspond with ISO C11 and ISO C17. 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.
61+
62+
> [!NOTE]
63+
> At the time of release, the latest Windows SDK and UCRT libraries do not yet support C11 and C17 code. A pre-release 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).
64+
65+
When you specify **`/std:c11`** or **`/std:c17`**, MSVC supports all the required features of C11 and C17. The compiler options enable support for these functionalities:
66+
67+
- **`_Pragma`**
68+
69+
- **`restrict`**
70+
71+
- **`_Noreturn`** and \<stdnoreturn.h>
72+
73+
- **`_Alignas`**, **`_Alignof`** and \<stdalign.h>
74+
75+
- **`_Generic`** and \<tgmath.h>
76+
77+
- **`_Static_assert`**
78+
79+
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.
80+
81+
Since C17 is largely a bug fix release of ISO C11, MSVC support for C11 already includes all the relevant defect reports. At present, 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.
82+
83+
The compiler doesn't support any 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).
84+
85+
- There's no conforming multithreading, atomic, or complex number support in the Visual Studio 2019 version 16.8 release.
86+
87+
- `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).
88+
89+
- DR 400 support is currently unimplemented for `realloc`, because this change would break the ABI.
90+
91+
- Variable length array (VLA) support isn't planned. Variable length arrays are often less efficient than comparable fixed sized arrays. They're also inefficient compared to equivalent heap memory allocations, when safely and securely implemented. VLAs provide attack vectors comparable to `gets()`, which is deprecated and planned for removal.
92+
4993
### To set this compiler option in the Visual Studio development environment
5094

5195
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).
5296

5397
1. Select **Configuration Properties**, **C/C++**, **Language**.
5498

55-
1. In **C++ Language Standard**, choose the language standard to support from the dropdown control, then choose **OK** or **Apply** to save your changes.
99+
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.
56100

57101
## See also
58102

docs/c-language/c-keywords.md

Lines changed: 79 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,105 +1,128 @@
11
---
22
title: "C Keywords"
3-
ms.date: "10/09/2018"
3+
description: "Keywords in Standard C and Microsoft C compiler extensions."
4+
ms.date: 09/12/2020
45
helpviewer_keywords: ["keywords [C]", "redefining keywords", "Microsoft-specific keywords"]
56
ms.assetid: 2d932335-97bf-45cd-b367-4ae00db0ff42
67
---
78
# C Keywords
89

9-
"Keywords" are words that have special meaning to the C compiler. In translation phases 7 and 8, an identifier cannot have the same spelling and case as a C keyword. (See a description of [translation phases](../preprocessor/phases-of-translation.md) in the *Preprocessor Reference*; for information on identifiers, see [Identifiers](../c-language/c-identifiers.md).) The C language uses the following keywords:
10+
*Keywords* are words that have special meaning to the C compiler. In translation phases 7 and 8, an identifier can't have the same spelling and case as a C keyword. For more information, see [translation phases](../preprocessor/phases-of-translation.md) in the *Preprocessor Reference*. For more information on identifiers, see [Identifiers](../c-language/c-identifiers.md).
11+
12+
## Standard C keywords
13+
14+
The C language uses the following keywords:
1015

1116
:::row:::
1217
:::column:::
1318
**`auto`**\
14-
**`double`**\
15-
**`int`**\
16-
**`struct`**\
1719
**`break`**\
18-
**`else`**\
19-
**`long`**\
20-
**`switch`**
21-
:::column-end:::
22-
:::column:::
2320
**`case`**\
24-
**`enum`**\
25-
**`register`**\
26-
**`typedef`**\
2721
**`char`**\
28-
**`extern`**\
29-
**`return`**\
30-
**`union`**
22+
**`const`**\
23+
**`continue`**\
24+
**`default`**\
25+
**`do`**\
26+
**`double`**\
27+
**`else`**\
28+
**`enum`**
3129
:::column-end:::
3230
:::column:::
33-
**`const`**\
31+
**`extern`**\
3432
**`float`**\
35-
**`short`**\
36-
**`unsigned`**\
37-
**`continue`**\
3833
**`for`**\
39-
**`signed`**\
40-
**`void`**
34+
**`goto`**\
35+
**`if`**\
36+
**`inline`** <sup>1, a</sup>\
37+
**`int`**\
38+
**`long`**\
39+
**`register`**\
40+
**`restrict`** <sup>1, a</sup>\
41+
**`return`**
4142
:::column-end:::
4243
:::column:::
43-
**`default`**\
44-
**`goto`**\
44+
**`short`**\
45+
**`signed`**\
4546
**`sizeof`**\
46-
**`volatile`**\
47-
**`do`**\
48-
**`if`**\
4947
**`static`**\
50-
**`while`**
48+
**`struct`**\
49+
**`switch`**\
50+
**`typedef`**\
51+
**`union`**\
52+
**`unsigned`**\
53+
**`void`**\
54+
**`volatile`**
55+
:::column-end:::
56+
:::column:::
57+
**`while`**\
58+
**`_Alignas`** <sup>2, a</sup>\
59+
**`_Alignof`** <sup>2, a</sup>\
60+
**`_Atomic`** <sup>2, b</sup>\
61+
**`_Bool`** <sup>1, a</sup>\
62+
**`_Complex`** <sup>1, b</sup>\
63+
**`_Generic`** <sup>2, a</sup>\
64+
**`_Imaginary`** <sup>1, b</sup>\
65+
**`_Noreturn`** <sup>2, a</sup>\
66+
**`_Static_assert`** <sup>2, a</sup>\
67+
**`_Thread_local`** <sup>2, b</sup>
5168
:::column-end:::
5269
:::row-end:::
5370

54-
You can't redefine keywords. However, you can specify text to be substituted for keywords before compilation by using C [preprocessor directives](../preprocessor/preprocessor-directives.md).
71+
<sup>1</sup> Keywords introduced in ISO C99.
5572

56-
**Microsoft Specific**
73+
<sup>2</sup> Keywords introduced in ISO C11.
5774

58-
The ANSI C standard allows identifiers with two leading underscores to be reserved for compiler implementations. Therefore, the Microsoft convention is to precede Microsoft-specific keyword names with double underscores. These words cannot be used as identifier names. For a description of the ANSI rules for naming identifiers, including the use of double underscores, see [Identifiers](../c-language/c-identifiers.md).
75+
<sup>a</sup> Starting in Visual Studio 2019 version 16.8, these keywords are supported in code compiled as C when the **`/std:c11`** or **`/std:c17`** compiler options are specified.
76+
77+
<sup>b</sup> Starting in Visual Studio 2019 version 16.8, these keywords are recognized but not supported by the compiler in code compiled as C when the **`/std:c11`** or **`/std:c17`** compiler options are specified.
78+
79+
You can't redefine keywords. However, you can specify text to replace keywords before compilation by using C [preprocessor directives](../preprocessor/preprocessor-directives.md).
80+
81+
## Microsoft-specific C keywords
82+
83+
The ANSI and ISO C standards allow identifiers with two leading underscores to be reserved for compiler implementations. The Microsoft convention is to precede Microsoft-specific keyword names with double underscores. These words can't be used as identifier names. For a description of the rules for naming identifiers, including the use of double underscores, see [Identifiers](../c-language/c-identifiers.md).
5984

6085
The following keywords and special identifiers are recognized by the Microsoft C compiler:
6186

6287
:::row:::
6388
:::column:::
64-
**`__asm`**<sup>3</sup>\
65-
**`dllimport`**<sup>2</sup>\
66-
**`__int8`**<sup>3</sup>\
67-
**`naked`**<sup>2</sup>\
68-
**`__based`**<sup>1, 3</sup>
89+
**`__asm`**<sup>5</sup>\
90+
**`dllimport`**<sup>4</sup>\
91+
**`__int8`**<sup>5</sup>\
92+
**`naked`**<sup>4</sup>\
93+
**`__based`**<sup>3, 5</sup>
6994
:::column-end:::
7095
:::column:::
71-
**`__except`**<sup>3</sup>\
72-
**`__int16`**<sup>3</sup>\
73-
**`__stdcall`**<sup>3</sup>\
74-
**`__cdecl`**<sup>3</sup>\
96+
**`__except`**<sup>5</sup>\
97+
**`__int16`**<sup>5</sup>\
98+
**`__stdcall`**<sup>5</sup>\
99+
**`__cdecl`**<sup>5</sup>\
75100
**`__fastcall`**
76101
:::column-end:::
77102
:::column:::
78-
**`__int32`**<sup>3</sup>\
79-
**`thread`**<sup>2</sup>\
80-
**`__declspec`**<sup>3</sup>\
81-
**`__finally`**<sup>3</sup>\
82-
**`__int64`**<sup>3</sup>
103+
**`__int32`**<sup>5</sup>\
104+
**`thread`**<sup>4</sup>\
105+
**`__declspec`**<sup>5</sup>\
106+
**`__finally`**<sup>5</sup>\
107+
**`__int64`**<sup>5</sup>
83108
:::column-end:::
84109
:::column:::
85-
**`__try`**<sup>3</sup>\
86-
**`dllexport`**<sup>2</sup>\
87-
**`__inline`**<sup>3</sup>\
88-
**`__leave`**<sup>3</sup>
110+
**`__try`**<sup>5</sup>\
111+
**`dllexport`**<sup>4</sup>\
112+
**`__inline`**<sup>5</sup>\
113+
**`__leave`**<sup>5</sup>
89114
:::column-end:::
90115
:::row-end:::
91116

92-
<sup>1</sup> The **`__based`** keyword has limited uses for 32-bit and 64-bit target compilations.
93-
94-
<sup>2</sup> These are special identifiers when used with **`__declspec`**; their use in other contexts is not restricted.
117+
<sup>3</sup> The **`__based`** keyword has limited uses for 32-bit and 64-bit target compilations.
95118

96-
<sup>3</sup> For compatibility with previous versions, these keywords are available both with two leading underscores and a single leading underscore when Microsoft extensions are enabled.
119+
<sup>4</sup> These are special identifiers when used with **`__declspec`**; their use in other contexts is unrestricted.
97120

98-
Microsoft extensions are enabled by default. To ensure that your programs are fully portable, you can disable Microsoft extensions by specifying the [/Za \(Disable language extensions)](../build/reference/za-ze-disable-language-extensions.md) option during compilation. When you do this, some Microsoft-specific keywords are disabled.
121+
<sup>5</sup> For compatibility with previous versions, these keywords are available both with two leading underscores and a single leading underscore when Microsoft extensions are enabled.
99122

100-
When Microsoft extensions are enabled, you can use the keywords listed above in your programs. For ANSI compliance, most of these keywords are prefaced by a double underscore. The four exceptions, **`dllexport`**, **`dllimport`**, **`naked`**, and **`thread`**, are used only with **`__declspec`** and therefore do not require a leading double underscore. For backward compatibility, single-underscore versions of the rest of the keywords are supported.
123+
Microsoft extensions are enabled by default. To assist in creating portable code, you can disable Microsoft extensions by specifying the [/Za \(Disable language extensions)](../build/reference/za-ze-disable-language-extensions.md) option during compilation. When you use this option, some Microsoft-specific keywords are disabled.
101124

102-
**END Microsoft Specific**
125+
When Microsoft extensions are enabled, you can use the keywords listed above in your programs. For standards compliance, most of these keywords are prefaced by a double underscore. The four exceptions, **`dllexport`**, **`dllimport`**, **`naked`**, and **`thread`**, are used only with **`__declspec`** and don't require a leading double underscore. For backward compatibility, single-underscore versions of the rest of the keywords are supported.
103126

104127
## See also
105128

0 commit comments

Comments
 (0)