Skip to content

fix(win): compile cleanly with MinGW GCC#1226

Open
Oxygen56 wants to merge 1 commit into
DeusData:mainfrom
Oxygen56:fix/windows-werror-build
Open

fix(win): compile cleanly with MinGW GCC#1226
Oxygen56 wants to merge 1 commit into
DeusData:mainfrom
Oxygen56:fix/windows-werror-build

Conversation

@Oxygen56

Copy link
Copy Markdown

Fixes #1225

What does this PR do?

Makes the Windows sources compile cleanly with MinGW GCC when warnings are treated as errors.

  • Removes a redundant DWORD range comparison that GCC reports as always false on 64-bit Windows. The existing MAXDWORD guard keeps the subsequent +1 safe, while calloc retains allocation-overflow handling.
  • Converts dynamically resolved Windows functions through GCC's generic void (*)(void) function-pointer type before assigning their concrete signatures.
  • Applies the same conversion to the Windows IPC regression test helpers.

Root cause

MinGW defines FARPROC as an unspecified-parameter function pointer. Direct casts from it to concrete Win32 function signatures trigger -Wcast-function-type. Separately, a DWORD can never exceed the 64-bit SIZE_MAX-based bound, so -Wtype-limits rejects that comparison under -Werror.

Verification

  • Unmodified origin/main reproduced both warning classes with x86_64-w64-mingw32-gcc 16.1.0 -Wall -Wextra -Werror.
  • The affected production translation units compile cleanly with the same MinGW GCC flags after the fix.
  • The Windows IPC test translation unit compiles cleanly for the affected warning class; -Wno-stringop-overflow was used only to isolate pre-existing unrelated diagnostics in that file.
  • make -f Makefile.cbm test — 6776 passed, 4 skipped.
  • make -f Makefile.cbm lint-ci — passed.
  • scripts/check-dco.sh origin/main..HEAD — passed.

Checklist

  • Every commit is signed off (git commit -s) — required, CI rejects
    unsigned commits (DCO, see CONTRIBUTING.md)
  • Tests pass locally (make -f Makefile.cbm test)
  • Lint passes (make -f Makefile.cbm lint-ci)
  • New behavior is covered by a test (reproduce-first for bug fixes)

Signed-off-by: Oxygen56 <jiangth99@163.com>
@Oxygen56
Oxygen56 requested a review from DeusData as a code owner July 23, 2026 11:22
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.

Not compiling on windows (again)

1 participant