Skip to content

Commit 2a47ee2

Browse files
author
Colin Robertson
committed
Add /Zc:preprocessor article
1 parent 51488f2 commit 2a47ee2

6 files changed

Lines changed: 50 additions & 17 deletions

File tree

docs/build/reference/experimental-preprocessor.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,31 @@
11
---
22
title: "/experimental:preprocessor (Enable preprocessor conformance mode)"
33
description: "Use the /experimental:preprocessor compiler option to enable experimental compiler support for a standard conforming preprocessor."
4-
ms.date: "10/31/2019"
4+
ms.date: 09/10/2020
55
f1_keywords: ["preprocessor", "/experimental:preprocessor"]
66
helpviewer_keywords: ["preprocessor conformance", "/experimental:preprocessor", "Enable preprocessor conformance mode"]
77
---
8-
# /experimental:preprocessor (Enable preprocessor conformance mode)
8+
# `/experimental:preprocessor` (Enable preprocessor conformance mode)
99

10-
This option enables an experimental, token-based preprocessor that more closely conforms to C++11 standards, including C99 preprocessor features. For more information, see [MSVC experimental preprocessor overview](../../preprocessor/preprocessor-experimental-overview.md).
10+
This option is obsolete starting in Visual Studio 2019 version 16.5, replaced by the [`/Zc:preprocessor`](zc-preprocessor.md) compiler option. **`/experimental:preprocessor`** enables an experimental, token-based preprocessor that more closely conforms to C++11 standards, including C99 preprocessor features. For more information, see [MSVC new preprocessor overview](../../preprocessor/preprocessor-experimental-overview.md).
1111

1212
## Syntax
1313

14-
> **/experimental:preprocessor**[**-**]
14+
> **`/experimental:preprocessor`**\[**`-`**]
1515
1616
## Remarks
1717

18-
Use the **/experimental:preprocessor** compiler option to enable the experimental conforming preprocessor. You can use **/experimental:preprocessor-** option to explicitly specify the traditional preprocessor.
18+
Use the **`/experimental:preprocessor`** compiler option to enable the experimental conforming preprocessor. You can use **`/experimental:preprocessor-`** option to explicitly specify the traditional preprocessor.
1919

20-
The **/experimental:preprocessor** option is available starting in Visual Studio 2017 version 15.8.
20+
The **`/experimental:preprocessor`** option is available starting in Visual Studio 2017 version 15.8. Starting in Visual Studio 2019 version 16.5, the new preprocessor is complete, and available under the [`/Zc:preprocessor`](zc-preprocessor.md) compiler option.
2121

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

2424
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).
2525

2626
1. Select the **Configuration Properties** > **C/C++** > **Command Line** property page.
2727

28-
1. Modify the **Additional Options** property to include **/experimental:preprocessor** and then choose **OK**.
28+
1. Modify the **Additional Options** property to include *`/experimental:preprocessor`* and then choose **OK**.
2929

3030
## See also
3131

docs/build/reference/zc-conformance.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ These are the **`/Zc`** compiler options:
2828
| [`/ZcimplicitNoexcept`](zc-implicitnoexcept-implicit-exception-specifiers.md) | Enable implicit **`noexcept`** on required functions (on by default). |
2929
| [`/Zc:inline`](zc-inline-remove-unreferenced-comdat.md) | Remove unreferenced function or data if it is COMDAT or has internal linkage only (off by default). |
3030
| [`/Zc:noexceptTypes`](zc-noexcepttypes.md) | Enforce C++17 **`noexcept`** rules (on by default in C++17 or later). |
31+
| [`/Zc:preprocessor`](zc-preprocessor.md) | Use the new conforming preprocessor (off by default, except in C11/C17). |
3132
| [`/Zc:referenceBinding`](zc-referencebinding-enforce-reference-binding-rules.md) | A UDT temporary will not bind to an non-const lvalue reference (off by default). |
3233
| [`/Zc:rvalueCast`](zc-rvaluecast-enforce-type-conversion-rules.md) | Enforce Standard C++ explicit type conversion rules (off by default). |
3334
| [`/Zc:sizedDealloc`](zc-sizeddealloc-enable-global-sized-dealloc-functions.md) | Enable C++14 global sized deallocation functions (on by default). |
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
---
2+
title: "/Zc:preprocessor (Enable preprocessor conformance mode)"
3+
description: "Use the /Zc:preprocessor compiler option to enable compiler support for a standard conforming preprocessor."
4+
ms.date: 09/10/2020
5+
f1_keywords: ["preprocessor", "/Zc:preprocessor"]
6+
helpviewer_keywords: ["preprocessor conformance", "/Zc:preprocessor", "Enable preprocessor conformance mode"]
7+
---
8+
# `/Zc:preprocessor` (Enable preprocessor conformance mode)
9+
10+
This option enables a token-based preprocessor that conforms to C99 and C++11 and later standards. For more information, see [MSVC new preprocessor overview](../../preprocessor/preprocessor-experimental-overview.md).
11+
12+
## Syntax
13+
14+
> **`/Zc:preprocessor`**[**-**]
15+
16+
## Remarks
17+
18+
Use the **`/Zc:preprocessor`** compiler option to enable the conforming preprocessor. You can use **`/Zc:preprocessor-`** option to explicitly specify the traditional (non-conforming) preprocessor.
19+
20+
The **`/Zc:preprocessor`** option is available starting in Visual Studio 2019 version 16.5. An earlier, incomplete version of the new preprocessor option is available in versions of Visual Studio starting in Visual Studio 2017 version 15.8. For more information, see [`/experimental:preprocessor`](experimental-preprocessor.md).
21+
22+
### To set this compiler option in the Visual Studio development environment
23+
24+
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).
25+
26+
1. Select the **Configuration Properties** > **C/C++** > **Command Line** property page.
27+
28+
1. Modify the **Additional Options** property to include *`/Zc:preprocessor`* and then choose **OK**.
29+
30+
## See also
31+
32+
[/Zc (Conformance)](zc-conformance.md)

docs/build/toc.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -744,6 +744,8 @@
744744
href: ../build/reference/zc-inline-remove-unreferenced-comdat.md
745745
- name: "/Zc:noexceptTypes (C++17 noexcept rules)"
746746
href: ../build/reference/zc-noexcepttypes.md
747+
- name: "/Zc:preprocessor (Enable preprocessor conformance mode)"
748+
href: ../build/reference/zc-preprocessor.md
747749
- name: "/Zc:referenceBinding (Enforce reference binding rules)"
748750
href: ../build/reference/zc-referencebinding-enforce-reference-binding-rules.md
749751
- name: "/Zc:rvalueCast (Enforce type conversion rules)"

docs/porting/visual-cpp-porting-and-upgrading-guide.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: "Microsoft C++ porting and upgrading guide"
33
description: "Upgrade Microsoft C++ code to the latest version of Visual Studio."
4-
ms.date: "11/18/2019"
4+
ms.date: 09/10/2020
55
ms.assetid: f5fbcc3d-aa72-41a6-ad9a-a706af2166fb
66
ms.topic: "overview"
77
---
@@ -23,7 +23,7 @@ If a legacy application is running satisfactorily, in a secure environment, and
2323

2424
- Build times are faster, because of performance improvements in the compiler and linker.
2525

26-
- Better standards conformance. The [/permissive-](../build/reference/permissive-standards-conformance.md) compiler option helps you identify code that doesn't conform to the current C++ standard.
26+
- Better standards conformance. The [/permissive-](../build/reference/permissive-standards-conformance.md) compiler option helps you identify code that doesn't conform to the current C++ standard. The [new preprocessor](../preprocessor/preprocessor-experimental-overview.md) supports code conformance, too.
2727

2828
- Better run-time security, including more secure [C Runtime library](../c-runtime-library/security-features-in-the-crt.md) features. And, compiler features such as [guard checking](../build/reference/guard-enable-guard-checks.md) and address sanitizers (new in Visual Studio 2019 version 16.4).
2929

docs/preprocessor/preprocessor-experimental-overview.md

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
2-
title: "MSVC experimental preprocessor overview"
2+
title: "MSVC new preprocessor overview"
33
description: "The MSVC preprocessor is being updated for conformance with C/C++ standards."
4-
ms.date: "02/09/2020"
4+
ms.date: 09/10/2020
55
helpviewer_keywords: ["preprocessor, experimental"]
66
---
77
# MSVC experimental preprocessor overview
@@ -16,13 +16,11 @@ Visual Studio 2015 uses the traditional preprocessor, which doesn't conform with
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-
These changes are available by using the [/experimental:preprocessor](../build/reference/experimental-preprocessor.md) compiler switch in Visual Studio 2017 or Visual Studio 2019. The default preprocessor behavior remains the same as in previous versions.
20-
21-
Starting in Visual Studio 2019 version 16.5, experimental preprocessor support for the C++20 standard is feature-complete.
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.
2220

2321
## New predefined macro
2422

25-
You can detect which preprocessor is in use at compile time. Check the value of the predefined macro [\_MSVC\_TRADITIONAL](predefined-macros.md) to tell if the traditional preprocessor is in use. This macro is set unconditionally by versions of the compiler that support it, independent of which preprocessor is invoked. Its value is 1 for the traditional preprocessor. It's 0 for the conforming preprocessor.
23+
You can detect which preprocessor is in use at compile time. Check the value of the predefined macro [`_MSVC_TRADITIONAL`](predefined-macros.md) to tell if the traditional preprocessor is in use. This macro is set unconditionally by versions of the compiler that support it, independent of which preprocessor is invoked. Its value is 1 for the traditional preprocessor. It's 0 for the conforming preprocessor.
2624

2725
```cpp
2826
#if defined(_MSVC_TRADITIONAL) && _MSVC_TRADITIONAL
@@ -238,9 +236,9 @@ DO_THING_FIXED(1, "World");
238236
// do_thing_one( "Hello", "World");
239237
```
240238

241-
## Incomplete features
239+
## Incomplete features before 16.5
242240

243-
Starting in Visual Studio 2019 version 16.5, the experimental 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:
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:
244242

245243
- Support for `_Pragma`
246244
- C++20 features

0 commit comments

Comments
 (0)