[PR #15604] Update /Zc build flags to be more standard conforming #30685

Closed
opened 2026-01-31 09:42:19 +00:00 by claunia · 0 comments
Owner

Original Pull Request: https://github.com/microsoft/terminal/pull/15604

State: closed
Merged: Yes


This commit removes some flags that we don't need anymore, and adds all
those /Zc (standard conformance) switches that aren't enabled by
default yet. This will help us and the MSVC team detect bugs early.

This removes:

  • /fp:contract: With the addition of TIL_FAST_MATH_BEGIN
    all the code that benefits from FMA now uses /fp:fast.
  • /Zc:lambda: Automatically enabled with C++20.

This adds:

  • /Zc:__cplusplus / /Zc:__STDC__: Without these __cplusplus
    defaults to 199711L and __STDC__ remains undefined.
  • /Zc:enumTypes: The C++ standard specifies that an enum with
    unspecifies size has a size that fits its members exactly.
    An enum with byte-sized members has a sizeof of 1 and not 4.
  • /Zc:templateScope: Emit errors when shadowing template parameters.

And most importantly:

  • <RemoveUnreferencedCodeData>, which is /Zc:inline
    Without this, MSVC treats inline functions sort of like external
    linkage ones. You can declare an inline function in one file and
    then just define it in another. Or use an inline function from
    another file. With this flag, the compiler can stop emitting
    COMDAT references for these which reduces object file sizes.
**Original Pull Request:** https://github.com/microsoft/terminal/pull/15604 **State:** closed **Merged:** Yes --- This commit removes some flags that we don't need anymore, and adds all those `/Zc` (standard conformance) switches that aren't enabled by default yet. This will help us and the MSVC team detect bugs early. This removes: * `/fp:contract`: With the addition of `TIL_FAST_MATH_BEGIN` all the code that benefits from FMA now uses `/fp:fast`. * `/Zc:lambda`: Automatically enabled with C++20. This adds: * `/Zc:__cplusplus` / `/Zc:__STDC__`: Without these `__cplusplus` defaults to `199711L` and `__STDC__` remains undefined. * `/Zc:enumTypes`: The C++ standard specifies that an enum with unspecifies size has a size that fits its members exactly. An enum with byte-sized members has a `sizeof` of 1 and not 4. * `/Zc:templateScope`: Emit errors when shadowing template parameters. And most importantly: * `<RemoveUnreferencedCodeData>`, which is `/Zc:inline` Without this, MSVC treats `inline` functions sort of like external linkage ones. You can declare an inline function in one file and then just define it in another. Or use an inline function from another file. With this flag, the compiler can stop emitting COMDAT references for these which reduces object file sizes.
claunia added the pull-request label 2026-01-31 09:42:19 +00:00
Sign in to join this conversation.
No Label pull-request
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#30685