Skip to content

Commit 7847949

Browse files
Merge pull request MicrosoftDocs#4698 from MicrosoftDocs/main638294454595223785sync_temp
For protected CLA branch, push strategy should use PR and merge to target branch method to work around git push error
2 parents 1878e15 + 94822e7 commit 7847949

File tree

3 files changed

+40
-3
lines changed

3 files changed

+40
-3
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
---
2+
title: "/Zc:zc-checkGwOdr (Enforce Standard C++ ODR violations under /Gw)"
3+
description: "Learn about the Microsoft C++ /Zc:checkGwOdr compiler option for improving C++ standards conformance when using /Gw (Optimize global data)"
4+
ms.date: 08/31/2023
5+
f1_keywords: ["/Zc:checkGwOdr"]
6+
helpviewer_keywords: ["/Zc:checkGwOdr", "Zc:checkGwOdr", "-Zc:checkGwOdr"]
7+
---
8+
# `/Zc:checkGwOdr` (Enforce Standard C++ ODR violations under `/Gw`)
9+
10+
This switch enforces C++ standards conformance when using [`/Gw` (Optimize global data)](gw-optimize-global-data.md). When using `/Gw`, certain One Definition Rule (ODR) violations are ignored. This flag ensures that the appropriate errors are raised.
11+
12+
## Syntax
13+
14+
> **`/Zc:checkGwOdr`**\[**`-`**]
15+
16+
## Remarks
17+
18+
This switch is off by default.
19+
20+
To see an example of ODR violations that are ignored when using `/Gw`, see [Standards conformance improvements to /Gw](https://devblogs.microsoft.com/cppblog/standards-conformance-improvements-to-gw-in-visual-studio-version-17-5-preview-2/).
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:checkGwOdr`* or *`/Zc:checkGwOdr-`* and then choose **OK**.
29+
30+
## See also
31+
32+
[`/Zc` (Conformance)](zc-conformance.md)\
33+
[One Definition Rule (ODR)](https://en.wikipedia.org/wiki/One_Definition_Rule)\
34+
[Standards conformance improvements to /Gw](https://devblogs.microsoft.com/cppblog/standards-conformance-improvements-to-gw-in-visual-studio-version-17-5-preview-2/)

docs/build/reference/zc-conformance.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: "/Zc (Conformance)"
33
description: "The /Zc conformance compiler options enable or disable support for conforming or backward-compatible behavior."
4-
ms.date: 08/29/2023
4+
ms.date: 08/31/2023
55
helpviewer_keywords: ["/Zc compiler options [C++]", "-Zc compiler options [C++]", "Conformance compiler options", "Zc compiler options [C++]"]
66
---
77
# `/Zc` (Conformance)
@@ -27,6 +27,7 @@ Here are the **`/Zc`** compiler options:
2727
| [`/Zc:alignedNew[-]`](zc-alignednew.md) | Enable C++17 over-aligned dynamic allocation. Off by default unless **`/std:c++17`** or later is specified. |
2828
| [`/Zc:auto[-]`](zc-auto-deduce-variable-type.md) | Enforce the new Standard C++ meaning for **`auto`**. On by default. |
2929
| [`/Zc:char8_t[-]`](zc-char8-t.md) | Enable or disable C++20 native `u8` literal support as `const char8_t`. Off by default unless **`/std:c++20`** or later is specified. |
30+
| [`/Zc:checkGwOdr[-]`](zc-check-gwodr.md) | Enforce Standard C++ ODR violations under `/Gw`. |
3031
| [`/Zc:enumTypes[-]`](zc-enumtypes.md) | Enable Standard C++ rules for `enum` type deduction. Off by default. |
3132
| [`/Zc:externC[-]`](zc-externc.md) | Enforce Standard C++ rules for `extern "C"` functions. Off by default unless **`/permissive-`** is specified. |
3233
| [`/Zc:externConstexpr[-]`](zc-externconstexpr.md) | Enable external linkage for **`constexpr`** variables. Off by default. |

docs/build/toc.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -773,7 +773,7 @@ items:
773773
- name: /Zc (Conformance)
774774
expanded: false
775775
items:
776-
- name: /Zc (Conformance)
776+
- name: "/Zc (Conformance)"
777777
href: ../build/reference/zc-conformance.md
778778
- name: "/Zc:__cplusplus (Enable updated __cplusplus macro)"
779779
href: ../build/reference/zc-cplusplus.md
@@ -785,7 +785,9 @@ items:
785785
href: ../build/reference/zc-auto-deduce-variable-type.md
786786
- name: "/Zc:char8_t (Enable C++20 char8_t type)"
787787
href: ../build/reference/zc-char8-t.md
788-
- name: '/Zc:enumTypes (Enable enum type deduction)'
788+
- name: "/Zc:checkGwOdr (Enforce Standard C++ ODR violations under /Gw)"
789+
href: ../build/reference/zc-check-gwodr.md
790+
- name: "/Zc:enumTypes (Enable enum type deduction)"
789791
href: ../build/reference/zc-enumtypes.md
790792
- name: '/Zc:externC (Use Standard C++ extern "C" rules)'
791793
href: ../build/reference/zc-externc.md

0 commit comments

Comments
 (0)