You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/build/reference/permissive-standards-conformance.md
+2Lines changed: 2 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -129,6 +129,8 @@ void g() {
129
129
}
130
130
```
131
131
132
+
You can enable the hidden friend name lookup rules independently of **`/permissive`** by using [`/Zc:hiddenFriend`](./zc-hiddenfriend.md). If you want legacy behavior for hidden friend name lookup, but otherwise want **`/permissive-`** behavior, use the **`/Zc:hiddenFriend-`** option.
You can use the **`/Zc`** compiler options to specify standard or Microsoft-specific compiler behavior.
11
10
12
11
## Syntax
13
12
14
-
> **`/Zc:`**_option_{,_option_}
13
+
> **`/Zc:`**_option_{,_option_ ...}
14
+
15
+
You may set multiple **`/Zc`** options separated by commas in a single **`/Zc`** compiler option. If a **`/Zc`** option is enabled and disabled in the same command, the option that appears last is used.
15
16
16
17
## Remarks
17
18
18
-
When Visual Studio has implemented an extension to C or C++ that is not compatible with the standard, you can use a **`/Zc`** conformance option to specify standard-conforming or Microsoft-specific behavior. For some options, the Microsoft-specific behavior is the default, to prevent large-scale breaking changes to existing code. In other cases, the default is the standard behavior, where improvements in security, performance, or compatibility outweigh the costs of breaking changes. The default setting of each conformance option may change in newer versions of Visual Studio. For more information about each conformance option, see the topic for the specific option. The [`/permissive-`](permissive-standards-conformance.md) compiler option implicitly sets the conformance options that are not set by default to their conformant setting.
19
+
When Visual Studio has implemented an extension to C or C++ that is incompatible with the standard, you can use a **`/Zc`** conformance option to specify standard-conforming or Microsoft-specific behavior. For some options, the Microsoft-specific behavior is the default, to prevent large-scale breaking changes to existing code. In other cases, the default is the standard behavior, where improvements in security, performance, or compatibility outweigh the costs of breaking changes. The default setting of each conformance option may change in newer versions of Visual Studio. For more information about each conformance option, see the article for the specific option. The [`/permissive-`](permissive-standards-conformance.md) compiler option implicitly sets the conformance options that aren't set by default to their conforming settings.
19
20
20
-
These are the **`/Zc`** compiler options:
21
+
Here are the **`/Zc`** compiler options:
21
22
22
23
| Option | Behavior |
23
24
|--|--|
@@ -26,11 +27,12 @@ These are the **`/Zc`** compiler options:
26
27
|[`/Zc:__cplusplus`](zc-cplusplus.md)| Enable the `__cplusplus` macro to report the supported standard (off by default). |
27
28
|[`/Zc:externConstexpr`](zc-externconstexpr.md)| Enable external linkage for **`constexpr`** variables (off by default). |
28
29
|[`/Zc:forScope`](zc-forscope-force-conformance-in-for-loop-scope.md)| Enforce Standard C++ **`for`** scoping rules (on by default). |
30
+
|[`/Zc:hiddenFriend`](zc-hiddenfriend.md)| Enforce Standard C++ hidden friend rules (implied by **`/permissive-`**) |
29
31
|[`/Zc:implicitNoexcept`](zc-implicitnoexcept-implicit-exception-specifiers.md)| Enable implicit **`noexcept`** on required functions (on by default). |
30
-
|[`/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). |
32
+
|[`/Zc:inline`](zc-inline-remove-unreferenced-comdat.md)| Remove unreferenced functions or data if they're COMDAT or have internal linkage only (off by default). |
31
33
|[`/Zc:noexceptTypes`](zc-noexcepttypes.md)| Enforce C++17 **`noexcept`** rules (on by default in C++17 or later). |
32
34
|[`/Zc:preprocessor`](zc-preprocessor.md)| Use the new conforming preprocessor (off by default, except in C11/C17). |
33
-
|[`/Zc:referenceBinding`](zc-referencebinding-enforce-reference-binding-rules.md)| A UDT temporary will not bind to an non-const lvalue reference (off by default). |
35
+
|[`/Zc:referenceBinding`](zc-referencebinding-enforce-reference-binding-rules.md)| A UDT temporary won't bind to a non-const lvalue reference (off by default). |
34
36
|[`/Zc:rvalueCast`](zc-rvaluecast-enforce-type-conversion-rules.md)| Enforce Standard C++ explicit type conversion rules (off by default). |
35
37
|[`/Zc:sizedDealloc`](zc-sizeddealloc-enable-global-sized-dealloc-functions.md)| Enable C++14 global sized deallocation functions (on by default). |
36
38
|[`/Zc:strictStrings`](zc-strictstrings-disable-string-literal-type-conversion.md)| Disable string-literal to `char*` or `wchar_t*` conversion (off by default). |
@@ -41,9 +43,9 @@ These are the **`/Zc`** compiler options:
41
43
|[`/Zc:twoPhase`](zc-twophase.md)| Use non-conforming template parsing behavior (conforming by default). |
42
44
|[`/Zc:wchar_t`](zc-wchar-t-wchar-t-is-native-type.md)|**`wchar_t`** is a native type, not a typedef (on by default). |
43
45
44
-
For more information about conformance issues in Visual C++, see [Nonstandard Behavior](../../cpp/nonstandard-behavior.md).
46
+
For more information about conformance issues in MSVC, see [Nonstandard behavior](../../cpp/nonstandard-behavior.md).
# `/Zc:hiddenFriend` (Enforce Standard C++ hidden friend rules)
9
+
10
+
Specifies the compiler conforms to the C++ standard treatment of hidden friend functions or function templates.
11
+
12
+
## Syntax
13
+
14
+
> **`/Zc:hiddenFriend`**\[**`-`**]
15
+
16
+
## Remarks
17
+
18
+
The **`/Zc:hiddenFriend`** option enables a subset of the [`/permissive-`](permissive-standards-conformance.md) option behavior. It tells the compiler to conform to the standard for hidden friends. The compiler only includes hidden friends in [argument-dependent lookup](../../cpp/argument-dependent-name-koenig-lookup-on-functions.md) (ADL) for explicit instances or template parameters of the enclosing class type. The restriction allows you to use hidden friends to keep operations on a type from applying to implicit conversions. This option can improve build speed in code that can't otherwise use [`/permissive-`](permissive-standards-conformance.md).
19
+
20
+
A *hidden friend* is a **`friend`** function or function template declared only within a class or class template definition. By default, the Microsoft C++ compiler doesn't remove hidden friend declarations as candidates for overload resolution everywhere it should. This legacy behavior can slow the compiler down by including the hidden friend functions as possible candidates in more contexts.
21
+
22
+
Standard C++ hidden friend behavior is enabled by default under **`/permissive-`**. To specify legacy hidden friend behavior when the **`/permissive-`** option is specified, use **`/Zc:hiddenFriend-`**. Use of C++20 Modules requires standard hidden friend behavior.
23
+
24
+
The **`/Zc:hiddenFriend`** option is available starting in Visual Studio 2019 version 16.4.
25
+
26
+
For examples of compiler behavior when you specify **`/Zc:hiddenFriend`**, see [Hidden friend name lookup rules](./permissive-standards-conformance.md#hidden-friend-name-lookup-rules).
27
+
28
+
### To set this compiler option in the Visual Studio development environment
29
+
30
+
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).
Copy file name to clipboardExpand all lines: docs/overview/cpp-conformance-improvements.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1475,7 +1475,7 @@ The most common values for *option* are:
1475
1475
| Option | Description |
1476
1476
|--|--|
1477
1477
| **`/Zc:twoPhase-`** | Two Phase name lookup is required for C++20 Modules and implied by **`permissive-`**. |
1478
-
| **`/Zc:hiddenFriend-`** | Enables standard hidden friend name lookup rules. Requiredfor C++20 Modules and implied by **`permissive-`**. |
1478
+
| **`/Zc:hiddenFriend-`** | Standard hidden friend name lookup rules are requiredfor C++20 Modules and implied by **`permissive-`**. |
1479
1479
| **`/Zc:preprocessor-`** | The conforming preprocessor is required for C++20 header unit usage and creation only. Named Modules don't require this option. |
1480
1480
1481
1481
The [`/experimental:module`](../build/reference/experimental-module.md) option is still required to use the *`std.*`* Modules that ship with Visual Studio, because they're not standardized yet.
0 commit comments