Skip to content

Repo sync for protected CLA branch #4698

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Sep 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions docs/build/reference/zc-check-gwodr.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
---
title: "/Zc:zc-checkGwOdr (Enforce Standard C++ ODR violations under /Gw)"
description: "Learn about the Microsoft C++ /Zc:checkGwOdr compiler option for improving C++ standards conformance when using /Gw (Optimize global data)"
ms.date: 08/31/2023
f1_keywords: ["/Zc:checkGwOdr"]
helpviewer_keywords: ["/Zc:checkGwOdr", "Zc:checkGwOdr", "-Zc:checkGwOdr"]
---
# `/Zc:checkGwOdr` (Enforce Standard C++ ODR violations under `/Gw`)

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.

## Syntax

> **`/Zc:checkGwOdr`**\[**`-`**]
## Remarks

This switch is off by default.

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

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

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

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

1. Modify the **Additional Options** property to include *`/Zc:checkGwOdr`* or *`/Zc:checkGwOdr-`* and then choose **OK**.

## See also

[`/Zc` (Conformance)](zc-conformance.md)\
[One Definition Rule (ODR)](https://en.wikipedia.org/wiki/One_Definition_Rule)\
[Standards conformance improvements to /Gw](https://devblogs.microsoft.com/cppblog/standards-conformance-improvements-to-gw-in-visual-studio-version-17-5-preview-2/)
3 changes: 2 additions & 1 deletion docs/build/reference/zc-conformance.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
title: "/Zc (Conformance)"
description: "The /Zc conformance compiler options enable or disable support for conforming or backward-compatible behavior."
ms.date: 08/29/2023
ms.date: 08/31/2023
helpviewer_keywords: ["/Zc compiler options [C++]", "-Zc compiler options [C++]", "Conformance compiler options", "Zc compiler options [C++]"]
---
# `/Zc` (Conformance)
Expand All @@ -27,6 +27,7 @@ Here are the **`/Zc`** compiler options:
| [`/Zc:alignedNew[-]`](zc-alignednew.md) | Enable C++17 over-aligned dynamic allocation. Off by default unless **`/std:c++17`** or later is specified. |
| [`/Zc:auto[-]`](zc-auto-deduce-variable-type.md) | Enforce the new Standard C++ meaning for **`auto`**. On by default. |
| [`/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. |
| [`/Zc:checkGwOdr[-]`](zc-check-gwodr.md) | Enforce Standard C++ ODR violations under `/Gw`. |
| [`/Zc:enumTypes[-]`](zc-enumtypes.md) | Enable Standard C++ rules for `enum` type deduction. Off by default. |
| [`/Zc:externC[-]`](zc-externc.md) | Enforce Standard C++ rules for `extern "C"` functions. Off by default unless **`/permissive-`** is specified. |
| [`/Zc:externConstexpr[-]`](zc-externconstexpr.md) | Enable external linkage for **`constexpr`** variables. Off by default. |
Expand Down
6 changes: 4 additions & 2 deletions docs/build/toc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -773,7 +773,7 @@ items:
- name: /Zc (Conformance)
expanded: false
items:
- name: /Zc (Conformance)
- name: "/Zc (Conformance)"
href: ../build/reference/zc-conformance.md
- name: "/Zc:__cplusplus (Enable updated __cplusplus macro)"
href: ../build/reference/zc-cplusplus.md
Expand All @@ -785,7 +785,9 @@ items:
href: ../build/reference/zc-auto-deduce-variable-type.md
- name: "/Zc:char8_t (Enable C++20 char8_t type)"
href: ../build/reference/zc-char8-t.md
- name: '/Zc:enumTypes (Enable enum type deduction)'
- name: "/Zc:checkGwOdr (Enforce Standard C++ ODR violations under /Gw)"
href: ../build/reference/zc-check-gwodr.md
- name: "/Zc:enumTypes (Enable enum type deduction)"
href: ../build/reference/zc-enumtypes.md
- name: '/Zc:externC (Use Standard C++ extern "C" rules)'
href: ../build/reference/zc-externc.md
Expand Down