Skip to content
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

Enable more test coverage for warning C4668 ('MEOW' is not defined as a preprocessor macro) #4441

Merged
merged 6 commits into from
Mar 8, 2024

Conversation

StephanTLavavej
Copy link
Member

Warning C4668 is off-by-default, but quite useful because (1) we conventionally never want to rely on the Standard's behavior of expanding not-defined macros to 0, and (2) it can detect typos. We already have some test coverage for it:

#pragma warning(1 : 4668) // 'MEOW' is not defined as a preprocessor macro, replacing with '0' for '#if/#elif'

However, we haven't applied this warning to our entire test suite, so I've had to catch other PRs unintentionally expanding not-defined macros.

  • C4668: In std and tr1, enable warning C4668 'MEOW' is not defined as a preprocessor macro, replacing with '0' for '#if/#elif'.
    • I'm excluding libcxx because it doesn't follow our convention.
  • C4668: Disable warning C4668 around <Windows.h>.
    • This works around OS-23694920 "Windows SDK uses undefined _WIN32_WINNT_* version macros (which may subtly break code)".
  • C4668: Remove unnecessary inclusion of <Windows.h>.
  • C4668: #if WIDE => #ifdef WIDE
    • These occurrences were inconsistent.
  • C4668: Activate C99 logic in tr1/include/tdefs.h.
    • This is a behavioral change/enhancement (the code was previously inactive). It fixes "warning C4668: '__STDC_VERSION__' is not defined as a preprocessor macro, replacing with '0' for '#if/#elif'".
    • We don't usually mess with tr1, but this looks like a straightforward improvement, and it only takes effect when the "approximately equal" test is already going to fail.
  • C4668: Disable warning C4668 around <limits.h>.
    • This is the only product code change, to work around VSO-1985428 "<limits.h> emits warning C4668: '__STDC_WANT_SECURE_LIB__' is not defined as a preprocessor macro, replacing with '0' for '#if/#elif'".

…ed as a preprocessor macro, replacing with `'0'` for `'#if/#elif'`.
OS-23694920 "Windows SDK uses undefined `_WIN32_WINNT_*` version macros (which may subtly break code)"
These occurrences were inconsistent.
This is a behavioral change/enhancement (the code was previously inactive). Fixes:

warning C4668: '__STDC_VERSION__' is not defined as a preprocessor macro, replacing with '0' for '#if/#elif'
VSO-1985428 "`<limits.h>` emits warning C4668: `'__STDC_WANT_SECURE_LIB__'` is not defined as a preprocessor macro, replacing with `'0'` for `'#if/#elif'`"
@StephanTLavavej StephanTLavavej added the test Related to test code label Mar 4, 2024
@StephanTLavavej StephanTLavavej requested a review from a team as a code owner March 4, 2024 02:03
@StephanTLavavej StephanTLavavej self-assigned this Mar 6, 2024
@StephanTLavavej
Copy link
Member Author

I'm speculatively mirroring this to the MSVC-internal repo - please notify me if any further changes are pushed.

@StephanTLavavej StephanTLavavej merged commit 6f8f8e3 into microsoft:main Mar 8, 2024
37 checks passed
@StephanTLavavej StephanTLavavej deleted the cleanups-3-c4668 branch March 8, 2024 05:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
test Related to test code
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

1 participant