Skip to content

Repo sync for protected CLA branch #4278

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 10 commits into from
Nov 9, 2022
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
Original file line number Diff line number Diff line change
Expand Up @@ -233,11 +233,11 @@ This table contains an alphabetical list of compiler options. For a list of comp
| [`/Zc:ternary[-]`](zc-ternary.md) | Enforce conditional operator rules on operand types (off by default). |
| [`/Zc:threadSafeInit[-]`](zc-threadsafeinit-thread-safe-local-static-initialization.md) | Enable thread-safe local static initialization (on by default). |
| [`/Zc:throwingNew[-]`](zc-throwingnew-assume-operator-new-throws.md) | Assume **`operator new`** throws on failure (off by default). |
| `/Zc:tlsGuards[-]` | Generate runtime checks for TLS variable initialization (on by default). |
| [`/Zc:tlsGuards[-]`](zc-tlsguards.md) | Generate runtime checks for TLS variable initialization (on by default). |
| [`/Zc:trigraphs`](zc-trigraphs-trigraphs-substitution.md) | Enable trigraphs (obsolete, off by default). |
| [`/Zc:twoPhase[-]`](zc-twophase.md) | Use non-conforming template parsing behavior (conforming by default). |
| [`/Zc:wchar_t[-]`](zc-wchar-t-wchar-t-is-native-type.md) | **`wchar_t`** is a native type, not a typedef (on by default). |
| `/Zc:zeroSizeArrayNew[-]` | Call member `new`/`delete` for 0-size arrays of objects (on by default). |
| [`/Zc:zeroSizeArrayNew[-]`](zc-zerosizearraynew.md) | Call member `new`/`delete` for 0-size arrays of objects (on by default). |
| [`/Ze`](za-ze-disable-language-extensions.md) | Deprecated. Enables C89 language extensions. |
| [`/Zf`](zf.md) | Improves PDB generation time in parallel builds. |
| [`/ZH:[MD5|SHA1|SHA_256]`](zh.md) | Specifies MD5, SHA-1, or SHA-256 for checksums in debug info. |
Expand All @@ -246,7 +246,7 @@ This table contains an alphabetical list of compiler options. For a list of comp
| [`/Zl`](zl-omit-default-library-name.md) | Removes the default library name from the *`.obj`* file. |
| [`/Zm`](zm-specify-precompiled-header-memory-allocation-limit.md) | Specifies the precompiled header memory allocation limit. |
| [`/Zo[-]`](zo-enhance-optimized-debugging.md) | Generate richer debugging information for optimized code. |
| [`/Zp[n]`](zp-struct-member-alignment.md) *n* | Packs structure members. |
| [`/Zp[n]`](zp-struct-member-alignment.md) | Packs structure members. |
| [`/Zs`](zs-syntax-check-only.md) | Checks syntax only. |
| [`/ZW`](zw-windows-runtime-compilation.md) | Produces an output file to run on the Windows Runtime. |

Expand Down
6 changes: 3 additions & 3 deletions docs/build/reference/compiler-options-listed-by-category.md
Original file line number Diff line number Diff line change
Expand Up @@ -195,19 +195,19 @@ This article contains a categorical list of compiler options. For an alphabetica
| [`/Zc:ternary[-]`](zc-ternary.md) | Enforce conditional operator rules on operand types (off by default). |
| [`/Zc:threadSafeInit[-]`](zc-threadsafeinit-thread-safe-local-static-initialization.md) | Enable thread-safe local static initialization (on by default). |
| [`/Zc:throwingNew[-]`](zc-throwingnew-assume-operator-new-throws.md) | Assume **`operator new`** throws on failure (off by default). |
| [`/Zc:tlsGuards[-]`](zc-tlsguards.md) | Generate runtime checks for TLS variable initialization (on by default). |
| [`/Zc:trigraphs`](zc-trigraphs-trigraphs-substitution.md) | Enable trigraphs (obsolete, off by default). |
| `/Zc:tlsGuards[-]` | Generate runtime checks for TLS variable initialization (on by default). |
| [`/Zc:twoPhase[-]`](zc-twophase.md) | Use non-conforming template parsing behavior (conforming by default). |
| [`/Zc:wchar_t[-]`](zc-wchar-t-wchar-t-is-native-type.md) | **`wchar_t`** is a native type, not a typedef (on by default). |
| `/Zc:zeroSizeArrayNew[-]` | Call member `new`/`delete` for 0-size arrays of objects (on by default). |
| [`/Zc:zeroSizeArrayNew[-]`](zc-zerosizearraynew.md) | Call member `new`/`delete` for 0-size arrays of objects (on by default). |
| [`/Ze`](za-ze-disable-language-extensions.md) | Deprecated. Enables C89 language extensions. |
| [`/Zf`](zf.md) | Improves PDB generation time in parallel builds. |
| [`/ZH:[MD5|SHA1|SHA_256]`](zh.md) | Specifies MD5, SHA-1, or SHA-256 for checksums in debug info. |
| [`/ZI`](z7-zi-zi-debug-information-format.md) | Includes debug information in a program database compatible with Edit and Continue. (x86 only) |
| [`/Zi`](z7-zi-zi-debug-information-format.md) | Generates complete debugging information. |
| [`/Zl`](zl-omit-default-library-name.md) | Removes the default library name from the *`.obj`* file. |
| [`/Zo[-]`](zo-enhance-optimized-debugging.md) | Generate richer debugging information for optimized code. |
| [`/Zp[n]`](zp-struct-member-alignment.md) *n* | Packs structure members. |
| [`/Zp[n]`](zp-struct-member-alignment.md) | Packs structure members. |
| [`/Zs`](zs-syntax-check-only.md) | Checks syntax only. |
| [`/ZW`](zw-windows-runtime-compilation.md) | Produces an output file to run on the Windows Runtime. |

Expand Down
8 changes: 4 additions & 4 deletions docs/build/reference/header-unit-json-reference.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
description: "Reference for header-units.json file"
title: "C++ header unit.json reference"
ms.date: 02/11/2022
ms.date: 11/09/2022
author: "tylermsft"
ms.author: "twhitney"
f1_keywords: ["header-units.json"]
Expand Down Expand Up @@ -45,9 +45,9 @@ The `header-units.json` in this directory can contain `a.h` and `b.h`, but not `
}
```

The reason `macros.h` can't be listed in this `header-units.json` file is that during the scan phase, the header unit (`.ifc`) might not be compiled yet for `macros.h`. In that case, `MACRO` won't be defined when `a.h` is compiled. That means `b.h` will be missing from the list of dependencies for `a.h`. Because it isn't in the list of dependencies, the build system won't build a header unit for `b.h` despite it being listed in the `header-units.json` file.
The reason `macros.h` can't be listed in this `header-units.json` file is that during the scan phase, the header unit (`.ifc`) might not be compiled yet for `macros.h`. In that case, `MACRO` won't be defined when `a.h` is compiled. That means `b.h` will be missing from the list of dependencies for `a.h`. Since it isn't in the list of dependencies, the build system won't build a header unit for `b.h` despite it being listed in the `header-units.json` file.

To avoid this problem when there's a dependency on a macro in another header file, the header file that defines the macro is excluded from the list of files that can be compiled into a header unit. This way the header file that defines the macro is treated as an `#include` and `MACRO` will be visible so that `b.h` is included and listed as one of the dependencies.
To avoid this problem, when there's a dependency on a macro in another header file, the header file that defines the macro is excluded from the list of files that can be compiled into a header unit. This way the header file that defines the macro is treated as a normal `#include` and `MACRO` will be visible so that `b.h` is included and listed as one of the dependencies.

### Preventing duplicated symbols

Expand All @@ -69,7 +69,7 @@ import "c.h";

If the compiler built header units for `a.h`, `b.h` and `c.h`, then the compiled header units `a.h.ifc`, `b.h.ifc`, and `c.h.ifc` would each contain all of the types from `b.h`. Compiling `Source.cpp`, which imports both `a.h` and `c.h`, would require the compiler to deduplicate the `b.h` types, which would impact build performance.

But if there's a `header-units.json` in the `b.h` directory, and `/translateInclude` is specified, the following happens:
But if there's a `header-units.json` in the `b.h` directory, and `/translateInclude` is specified, then the following happens:

1. The scan of `a.h` and `c.h` lists `b.h` as a header unit import in the dependency scan files generated by the compiler.
1. The build system reads the dependency scan files and determines to build `b.h.ifc` first.
Expand Down
8 changes: 6 additions & 2 deletions 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: 12/02/2021
ms.date: 11/08/2022
helpviewer_keywords: ["/Zc compiler options [C++]", "-Zc compiler options [C++]", "Conformance compiler options", "Zc compiler options [C++]"]
---
# `/Zc` (Conformance)
Expand All @@ -22,10 +22,12 @@ Here are the **`/Zc`** compiler options:

| Option | Behavior |
|--|--|
| [`/Zc:__cplusplus`](zc-cplusplus.md) | Enable the `__cplusplus` macro to report the supported standard (off by default). |
| [`/Zc:__STDC__`](zc-stdc.md) | Enable the `__STDC__` macro to report the C standard is supported (off by default). |
| [`/Zc:alignedNew`](zc-alignednew.md) | Enable C++17 over-aligned dynamic allocation (on by default in C++17). |
| [`/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, except under **`/std:c++20`**). |
| [`/Zc:__cplusplus`](zc-cplusplus.md) | Enable the `__cplusplus` macro to report the supported standard (off by default). |
| [`/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 (implied by **`/permissive-`**). |
| [`/Zc:externConstexpr`](zc-externconstexpr.md) | Enable external linkage for **`constexpr`** variables (off by default). |
| [`/Zc:forScope`](zc-forscope-force-conformance-in-for-loop-scope.md) | Enforce Standard C++ **`for`** scoping rules (on by default). |
Expand All @@ -43,9 +45,11 @@ Here are the **`/Zc`** compiler options:
| [`/Zc:ternary`](zc-ternary.md) | Enforce conditional operator rules on operand types (off by default). |
| [`/Zc:threadSafeInit`](zc-threadsafeinit-thread-safe-local-static-initialization.md) | Enable thread-safe local static initialization (on by default). |
| [`/Zc:throwingNew`](zc-throwingnew-assume-operator-new-throws.md) | Assume **`operator new`** throws on failure (off by default). |
| [`/Zc:tlsGuards[-]`](zc-tlsguards.md) | Generate runtime checks for TLS variable initialization (on by default). |
| [`/Zc:trigraphs`](zc-trigraphs-trigraphs-substitution.md) | Enable trigraphs (obsolete, off by default). |
| [`/Zc:twoPhase`](zc-twophase.md) | Use non-conforming template parsing behavior (conforming by default). |
| [`/Zc:wchar_t`](zc-wchar-t-wchar-t-is-native-type.md) | **`wchar_t`** is a native type, not a typedef (on by default). |
| [`/Zc:zeroSizeArrayNew[-]`](zc-zerosizearraynew.md) | Call member `new`/`delete` for 0-size arrays of objects (on by default). |

For more information about conformance issues in MSVC, see [Nonstandard behavior](../../cpp/nonstandard-behavior.md).

Expand Down
32 changes: 32 additions & 0 deletions docs/build/reference/zc-tlsguards.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
---
description: "Learn more about the /Zc:tlsGuards (Check TLS initialization) compiler option."
title: "/Zc:tlsGuards (Check TLS initialization)"
ms.date: 11/08/2022
f1_keywords: ["/Zc:tlsGuards"]
helpviewer_keywords: ["-Zc:tlsGuards compiler option (C++)", "/Zc:tlsGuards compiler option (C++)"]
---
# `/Zc:tlsGuards` (Check TLS initialization)

The **`/Zc:tlsGuards`** compiler option generates runtime checks for thread local storage (TLS) initialization in DLLs.

## Syntax

> **`/Zc:tlsGuards`**\[**`-`**]

## Remarks

The **`/Zc:tlsGuards`** compiler option enables checks for initialization of thread-local variables in DLLs. Previously, thread-local variables in DLLs weren't correctly initialized. Other than on the thread that loaded the DLL, they weren't initialized before first use on threads that existed before the DLL was loaded. The **`/Zc:tlsGuards`** option enables code that corrects this defect. Thread-local variables in such a DLL get initialized immediately before their first use on such threads.

The **`/Zc:tlsGuards`** option is new in Visual Studio 2019 version 16.5. This option is on by default in all compiler modes. The new behavior of testing for initialization on uses of thread-local variables may be disabled by using the **`/Zc:tlsGuards-`** compiler option. To disable checks for specific thread-local variables, use the [`[[msvc:no_tls_guard]]`](../../cpp/attributes.md) attribute.

### To set this compiler option in Visual Studio

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. In **Additional options**, add *`/Zc:tlsGuards`*. Choose **OK** or **Apply** to save your changes.

## See also

[`/Zc` (Conformance)](zc-conformance.md)\
32 changes: 32 additions & 0 deletions docs/build/reference/zc-zerosizearraynew.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
---
description: "Learn more about the /Zc:zeroSizeArrayNew (Call member new/delete on arrays) compiler option."
title: "/Zc:zeroSizeArrayNew (Call member new/delete on arrays)"
ms.date: 11/08/2022
f1_keywords: ["/Zc:zeroSizeArrayNew"]
helpviewer_keywords: ["-Zc:zeroSizeArrayNew compiler option (C++)", "/Zc:zeroSizeArrayNew compiler option (C++)"]
---
# `/Zc:zeroSizeArrayNew` (Call member new/delete on arrays)

The **`/Zc:zeroSizeArrayNew`** compiler option calls member `new` and `delete` for zero-length arrays of objects.

## Syntax

> **`/Zc:zeroSizeArrayNew`**\[**`-`**]

## Remarks

The **`/Zc:zeroSizeArrayNew`** compiler option enables calls to member `new` and `delete` for zero-length arrays of objects of class types with virtual destructors. This behavior conforms to the standard. This compiler option is new in Visual Studio 2019 version 16.9 and is enabled by default in all compiler modes. Previously, in code compiled by versions before Visual Studio 2019 version 16.9, the compiler invoked global `new` and `delete` on zero-length arrays of objects of class types with virtual destructors.

The **`/Zc:zeroSizeArrayNew`** option may cause a breaking change in code that relied on the previous non-conforming behavior. To restore the previous behavior, use the **`/Zc:zeroSizeArrayNew-`** compiler option.

### To set this compiler option in Visual Studio

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. In **Additional options**, add *`/Zc:zeroSizeArrayNew`* or *`/Zc:zeroSizeArrayNew-`*. Choose **OK** or **Apply** to save your changes.

## See also

[`/Zc` (Conformance)](zc-conformance.md)\
6 changes: 5 additions & 1 deletion docs/build/toc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -811,16 +811,20 @@ items:
href: ../build/reference/zc-strictstrings-disable-string-literal-type-conversion.md
- name: "/Zc:ternary (Enforce conditional operator rules)"
href: ../build/reference/zc-ternary.md
- name: "/Zc:threadSafeInit (Thread-safe local static initialization)"
- name: "/Zc:threadSafeInit (Thread-safe local static initialization)"
href: ../build/reference/zc-threadsafeinit-thread-safe-local-static-initialization.md
- name: "/Zc:throwingNew (Assume operator new throws)"
href: ../build/reference/zc-throwingnew-assume-operator-new-throws.md
- name: "/Zc:tlsGuards (Check TLS initialization)"
href: ../build/reference/zc-tlsguards.md
- name: "/Zc:trigraphs (Trigraphs substitution)"
href: ../build/reference/zc-trigraphs-trigraphs-substitution.md
- name: "/Zc:twoPhase- (disable two-phase name lookup)"
href: ../build/reference/zc-twophase.md
- name: "/Zc:wchar_t (wchar_t is native type)"
href: ../build/reference/zc-wchar-t-wchar-t-is-native-type.md
- name: "/Zc:zeroSizeArrayNew (Call member new/delete on arrays)"
href: ../build/reference/zc-zerosizearraynew.md
- name: /Zf (Faster PDB generation)
href: ../build/reference/zf.md
- name: /Zg (Generate function prototypes)
Expand Down
Loading