/Zc (Conformance)

Use the /Zc compiler options to specify standard or Microsoft-specific compiler behavior.

Syntax

/Zc:option{,option ...}

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.

Remarks

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- compiler option implicitly sets the conformance options that aren't set by default to their conforming settings.

Here are the /Zc compiler options:

Option Behavior
/Zc:__cplusplus[-] Enable the __cplusplus macro to report the supported standard. Off by default.
/Zc:__STDC__ Enable the __STDC__ macro to report the C standard is supported. Off by default.
/Zc:alignedNew[-] Enable C++17 over-aligned dynamic allocation. Off by default unless /std:c++17 or later is specified.
/Zc:auto[-] Enforce the new Standard C++ meaning for auto. On by default.
/Zc:char8_t[-] 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[-] Enforce Standard C++ ODR violations under /Gw.
/Zc:enumTypes[-] Enable Standard C++ rules for enum type deduction. Off by default.
/Zc:externC[-] Enforce Standard C++ rules for extern "C" functions. Off by default unless /permissive- is specified.
/Zc:externConstexpr[-] Enable external linkage for constexpr variables. Off by default.
/Zc:forScope[-] Enforce Standard C++ for scoping rules. On by default.
/Zc:gotoScope[-] Enforce Standard C++ goto rules around local variable initialization. Off by default unless /permissive- is specified.
/Zc:hiddenFriend[-] Enforce Standard C++ hidden friend rules. Off by default unless /permissive- is specified.
/Zc:implicitNoexcept[-] Enable implicit noexcept on required functions. On by default.
/Zc:inline[-] Remove unreferenced functions or data if they're COMDAT or have internal linkage only. Off by default.
/Zc:lambda[-] Enable new lambda processor for conformance-mode syntactic checks in generic lambdas. Off by default unless /std:c++20 or later is specified.
/Zc:noexceptTypes[-] Enforce C++17 noexcept rules. Off by default unless /std:c++17 or later is specified.
/Zc:nrvo[-] Enable optional copy and move elisions. Off by default unless /O2, /permissive-, or /std:c++20 or later is specified.
/Zc:preprocessor[-] Use the new conforming preprocessor. Off by default unless /std:c11 or later is specified.
/Zc:referenceBinding[-] A UDT temporary won't bind to a nonconst lvalue reference. Off by default unless /permissive- is specified.
/Zc:rvalueCast[-] Enforce Standard C++ explicit type conversion rules. Off by default unless /permissive- is specified.
/Zc:sizedDealloc[-] Enable C++14 global sized deallocation functions. On by default.
/Zc:strictStrings[-] Disable string-literal to char* or wchar_t* conversion. Off by default unless /permissive- is specified.
/Zc:static_assert[-] strict handling of static_assert. Off by default unless /permissive- is specified.
/Zc:templateScope[-] Enforce Standard C++ template parameter shadowing rules. Off by default.
/Zc:ternary[-] Enforce conditional operator rules on operand types. Off by default unless /permissive- is specified.
/Zc:threadSafeInit[-] Enable thread-safe local static initialization. On by default.
/Zc:throwingNew[-] Assume operator new throws on failure. Off by default.
/Zc:tlsGuards[-] Generate runtime checks for TLS variable initialization. On by default.
/Zc:trigraphs[-] Enable trigraphs (obsolete, off by default).
/Zc:twoPhase- Use nonconforming template parsing behavior (only applicable when /permissive- is specified, which defaults to conforming).
/Zc:wchar_t[-] 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.

For more information about conformance issues in MSVC, see Nonstandard behavior.

See also

MSVC compiler options
MSVC compiler command-line syntax