Skip to content

Test _WIN32 with defined() instead of by value - #1088

Merged
Jason Sandlin (jasonsandlin) merged 1 commit into
user/jasonsa/pal-msvc-only-pragmasfrom
user/jasonsa/wundef-win32
Nov 30, 2026
Merged

Jason Sandlin (jasonsandlin) merged 1 commit into
user/jasonsa/pal-msvc-only-pragmasfrom
user/jasonsa/wundef-win32

Conversation

@jasonsandlin

Copy link
Copy Markdown
Member

Agent assessment

Self-reported assessment, not an independent review.

Assessed revision: 28bf9b1d988afec00764f285bb66c557b62487fd

Dimension Assessment Rationale
Change confidence 9.5/10 ↑ Mechanical #if _WIN32 to #if defined(_WIN32); identical semantics everywhere.
↑ Header check with -Werror=undef passes for native and Generic; portable suite 242/242; MSVC TE build warning-free.
↓ CI legs beyond Linux clang and MSVC x64 Debug not yet observed.
Diagnosis confidence 10/10 ↑ Red run failed with the issue's exact pal.h:21:5 '_WIN32' is not defined diagnostic.
Evidence fit 9.5/10 ↑ A -Wundef build of the library now reports zero _WIN32 diagnostics (all 8 listed sites).
↓ Not verified with the actual PS5 SDK toolchain.

Fixes #1085

Stacked on #1087 (reuses its public-header check). Review/merge #1087 first; this PR then retargets to main.

Problem

Eight conditionals tested _WIN32 by value (#if _WIN32). Non-Windows toolchains don't define it, so clang/gcc report -Wundef. pal.h is included by every public header, so every consumer TU got the warning and -Werror builds failed.

Fix

#if _WIN32 → #if defined(_WIN32) at all sites listed in the issue: Include/httpClient/pal.h, Source/Common/utils.h, Source/Logger/trace.cpp, and five in Source/Task/AsyncLib.cpp. No bare #if _WIN32 remains under Include/ or Source/.

Test (red → green)

Adds -Werror=undef to the libHttpClient.PublicHeaderCheck.* options from #1087.

  • Red (before the fix): both variants fail with pal.h:21:5: error: '_WIN32' is not defined, evaluates to 0 [-Werror,-Wundef].
  • Green: both build; portable suite 242/242 (clang, ASan+UBSan); MSVC TE build warning-free.
  • The Source/ sites aren't in the public headers, so I checked them with a full -Wundef build of the library: zero _WIN32 diagnostics, down from about 160. Other internal -Wundef hits (HC_UWP_API, _MSC_VER, _MSVC_LANG, HC_NOZLIB) are out of scope here and don't reach consumers.

Eight preprocessor conditionals used `#if _WIN32`. Non-Windows toolchains
don't define _WIN32, so clang/gcc report -Wundef for each. pal.h is included
by every public header, so every consumer TU got the warning and -Werror
builds failed. Use `#if defined(_WIN32)` like the rest of the codebase;
behavior is identical on every platform.

Sites: Include/httpClient/pal.h, Source/Common/utils.h,
Source/Logger/trace.cpp and five in Source/Task/AsyncLib.cpp.

Extend the public header check with -Werror=undef so the public headers stay
-Wundef clean on the native and Generic platforms.

Fixes #1085

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@jasonsandlin
Jason Sandlin (jasonsandlin) merged commit dbc25ba into user/jasonsa/pal-msvc-only-pragmas Nov 30, 2026
2 checks passed
@jasonsandlin
Jason Sandlin (jasonsandlin) deleted the user/jasonsa/wundef-win32 branch November 30, 2026 21:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants