Skip to content

Commit 40f3a6a

Browse files
author
Colin Robertson
committed
New preprocessor is new
1 parent 2a47ee2 commit 40f3a6a

File tree

4 files changed

+18
-16
lines changed

4 files changed

+18
-16
lines changed

docs/overview/what-s-new-for-visual-cpp-in-visual-studio.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ The MSVC compiler toolset in Visual Studio version 15.7 now conforms with the C+
251251

252252
##### Visual Studio 2017 version 15.8
253253

254-
The [`/experimental:preprocessor`](../build/reference/experimental-preprocessor.md) compiler switch enables the new experimental MSVC preprocessor that will eventually conform to all applicable C and C++ standards. For more information, see [MSVC experimental preprocessor overview](../preprocessor/preprocessor-experimental-overview.md).
254+
The [`/experimental:preprocessor`](../build/reference/experimental-preprocessor.md) compiler switch enables the new experimental MSVC preprocessor that will eventually conform to all applicable C and C++ standards. For more information, see [MSVC new preprocessor overview](../preprocessor/preprocessor-experimental-overview.md).
255255

256256
### New compiler options
257257

docs/preprocessor/c-cpp-preprocessor-reference.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ ms.assetid: e4a52843-7016-4f6d-8b40-cb1ace18f805
88

99
The *C/C++ preprocessor reference* explains the preprocessor as it is implemented in Microsoft C/C++. The preprocessor performs preliminary operations on C and C++ files before they are passed to the compiler. You can use the preprocessor to conditionally compile code, insert files, specify compile-time error messages, and apply machine-specific rules to sections of code.
1010

11-
In Visual Studio 2019 the [/experimental:preprocessor](../build/reference/experimental-preprocessor.md) compiler option enables a new implementation of the preprocessor. The new implementation is still in progress, and is therefore considered experimental. It is intended to eventually be conformant with C99, C11, and C++20. For more information, see [MSVC experimental preprocessor overview](preprocessor-experimental-overview.md).
11+
In Visual Studio 2019 the [/experimental:preprocessor](../build/reference/experimental-preprocessor.md) compiler option enables a new implementation of the preprocessor. The new implementation is still in progress, and is therefore considered experimental. It is intended to eventually be conformant with C99, C11, and C++20. For more information, see [MSVC new preprocessor overview](preprocessor-experimental-overview.md).
1212

1313
## In this section
1414

docs/preprocessor/preprocessor-experimental-overview.md

+15-13
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,21 @@
22
title: "MSVC new preprocessor overview"
33
description: "The MSVC preprocessor is being updated for conformance with C/C++ standards."
44
ms.date: 09/10/2020
5-
helpviewer_keywords: ["preprocessor, experimental"]
5+
helpviewer_keywords: ["preprocessor, experimental", "preprocessor, new"]
66
---
7-
# MSVC experimental preprocessor overview
7+
# MSVC new preprocessor overview
88

99
::: moniker range="vs-2015"
1010

11-
Visual Studio 2015 uses the traditional preprocessor, which doesn't conform with Standard C++. An experimental preprocessor is available in Visual Studio 2017 and Visual Studio 2019 by using the [/experimental:preprocessor](../build/reference/experimental-preprocessor.md) compiler switch. More information about using the new preprocessor in Visual Studio 2017 and Visual Studio 2019 is available. To see the documentation for your preferred version of Visual Studio, use the **Version** selector control. It's found at the top of the table of contents on this page.
11+
Visual Studio 2015 uses the traditional preprocessor, which doesn't conform with Standard C++ or C99. Starting in Visual Studio 2019 version 16.5, new preprocessor support for the C++20 standard is feature-complete. These changes are available by using the [/Zc:preprocessor](../build/reference/zc-preprocessor.md) compiler switch. An experimental version of the new preprocessor is available starting in Visual Studio 2017 version 15.8 and later by using the [/experimental:preprocessor](../build/reference/experimental-preprocessor.md) compiler switch. More information about using the new preprocessor in Visual Studio 2017 and Visual Studio 2019 is available. To see the documentation for your preferred version of Visual Studio, use the **Version** selector control. It's found at the top of the table of contents on this page.
1212

1313
::: moniker-end
1414

1515
::: moniker range=">=vs-2017"
1616

1717
We're updating the Microsoft C++ preprocessor to improve standards conformance, fix longstanding bugs, and change some behaviors that are officially undefined. We've also added new diagnostics to warn on errors in macro definitions.
1818

19-
Starting in Visual Studio 2019 version 16.5, preprocessor support for the C++20 standard is feature-complete. These changes are available starting in Visual Studio 2019 version 16.5 by using the [/Zc:preprocessor](../build/reference/zc-preprocessor.md) compiler switch. An experimental version is available in earlier versions starting in Visual Studio 2017 version 15.8 by using the [/experimental:preprocessor](../build/reference/experimental-preprocessor.md) compiler switch. The default preprocessor behavior remains the same as in previous versions.
19+
Starting in Visual Studio 2019 version 16.5, preprocessor support for the C++20 standard is feature-complete. These changes are available by using the [/Zc:preprocessor](../build/reference/zc-preprocessor.md) compiler switch. An experimental version of the new preprocessor is available in earlier versions starting in Visual Studio 2017 version 15.8. You can enable it by using the [/experimental:preprocessor](../build/reference/experimental-preprocessor.md) compiler switch. The default preprocessor behavior remains the same as in previous versions.
2020

2121
## New predefined macro
2222

@@ -30,9 +30,9 @@ You can detect which preprocessor is in use at compile time. Check the value of
3030
#endif
3131
```
3232

33-
## Behavior changes in the experimental preprocessor
33+
## Behavior changes in the new preprocessor
3434

35-
The initial work on the experimental preprocessor has been focused on making all macro expansions conform to the standard. It lets you use the MSVC compiler with libraries that are currently blocked by the traditional behaviors. We tested the updated preprocessor on real world projects. Here are some of the more common breaking changes we found:
35+
The initial work on the new preprocessor has been focused on making all macro expansions conform to the standard. It lets you use the MSVC compiler with libraries that are currently blocked by the traditional behaviors. We tested the updated preprocessor on real world projects. Here are some of the more common breaking changes we found:
3636

3737
### Macro comments
3838

@@ -120,7 +120,7 @@ ADD_STD(string) s;
120120
121121
### Comma elision in variadic macros
122122
123-
The traditional MSVC preprocessor always removes commas before empty `__VA_ARGS__` replacements. The experimental preprocessor more closely follows the behavior of other popular cross-platform compilers. For the comma to be removed, the variadic argument must be missing (not just empty) and it must be marked with a `##` operator. Consider the following example:
123+
The traditional MSVC preprocessor always removes commas before empty `__VA_ARGS__` replacements. The new preprocessor more closely follows the behavior of other popular cross-platform compilers. For the comma to be removed, the variadic argument must be missing (not just empty) and it must be marked with a `##` operator. Consider the following example:
124124
125125
```cpp
126126
void func(int, int = 2, int = 3);
@@ -154,11 +154,11 @@ int main()
154154
}
155155
```
156156
157-
In the upcoming C++20 standard, this issue has been addressed by adding `__VA_OPT__`. Experimental preprocessor support for `__VA_OPT__` is available starting in Visual Studio 2019 version 16.5.
157+
In the upcoming C++20 standard, this issue has been addressed by adding `__VA_OPT__`. New preprocessor support for `__VA_OPT__` is available starting in Visual Studio 2019 version 16.5.
158158
159159
### C++20 variadic macro extension
160160
161-
The experimental preprocessor supports C++20 variadic macro argument elision:
161+
The new preprocessor supports C++20 variadic macro argument elision:
162162
163163
```cpp
164164
#define FUNC(a, ...) __VA_ARGS__ + a
@@ -169,7 +169,7 @@ int main()
169169
}
170170
```
171171

172-
This code isn't conforming before the C++20 standard. In MSVC, the experimental preprocessor extends this C++20 behavior to lower language standard modes (**`/std:c++14`**, **`/std:c++17`**). This extension matches the behavior of other major cross-platform C++ compilers.
172+
This code isn't conforming before the C++20 standard. In MSVC, the new preprocessor extends this C++20 behavior to lower language standard modes (**`/std:c++14`**, **`/std:c++17`**). This extension matches the behavior of other major cross-platform C++ compilers.
173173

174174
### Macro arguments are "unpacked"
175175

@@ -211,7 +211,9 @@ DO_THING(1, "World");
211211
// IMPL1 ( "Hello","World");
212212
```
213213

214-
Although this example may seem a bit contrived, we've seen it in real world code. To see what's going on, we can break down the expansion starting with `DO_THING`:
214+
Although this example may seem a bit contrived, we've seen it in real-world code.
215+
216+
To see what's going on, we can break down the expansion starting with `DO_THING`:
215217

216218
1. `DO_THING(1, "World")` expands to `CAT(IMPL, 1) ECHO(("Hello", "World"))`
217219
1. `CAT(IMPL, 1)` expands to `IMPL ## 1`, which expands to `IMPL1`
@@ -220,7 +222,7 @@ Although this example may seem a bit contrived, we've seen it in real world code
220222
1. The preprocessor moves on to the following tokens. It finds the function-like macro `ECHO` gets invoked: `ECHO(("Hello", "World"))`, which expands to `("Hello", "World")`
221223
1. `IMPL1` is never considered again for expansion, so the full result of the expansions is: `IMPL1("Hello", "World");`
222224

223-
To modify the macro to behave the same way under both the experimental preprocessor and the traditional preprocessor, add another layer of indirection:
225+
To modify the macro to behave the same way under both the new preprocessor and the traditional preprocessor, add another layer of indirection:
224226

225227
```cpp
226228
#define CAT(a,b) a##b
@@ -238,7 +240,7 @@ DO_THING_FIXED(1, "World");
238240

239241
## Incomplete features before 16.5
240242

241-
Starting in Visual Studio 2019 version 16.5, the new preprocessor is feature-complete for C++20. In previous versions of Visual Studio, the experimental preprocessor is mostly complete, although some preprocessor directive logic still falls back to the traditional behavior. Here's a partial list of incomplete features in Visual Studio versions before 16.5:
243+
Starting in Visual Studio 2019 version 16.5, the new preprocessor is feature-complete for C++20. In previous versions of Visual Studio, the new preprocessor is mostly complete, although some preprocessor directive logic still falls back to the traditional behavior. Here's a partial list of incomplete features in Visual Studio versions before 16.5:
242244

243245
- Support for `_Pragma`
244246
- C++20 features

docs/preprocessor/toc.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
items:
66
- name: Preprocessor
77
href: ../preprocessor/preprocessor.md
8-
- name: Experimental preprocessor overview
8+
- name: New preprocessor overview
99
href: ../preprocessor/preprocessor-experimental-overview.md
1010
- name: Phases of translation
1111
href: ../preprocessor/phases-of-translation.md

0 commit comments

Comments
 (0)