Skip to content

Fix Winsock type incompatibilities on modern MinGW-w64 (UCRT / GCC 16)#224

Open
johnnyvillanueva wants to merge 1 commit into
marlam:masterfrom
johnnyvillanueva:msys2
Open

Fix Winsock type incompatibilities on modern MinGW-w64 (UCRT / GCC 16)#224
johnnyvillanueva wants to merge 1 commit into
marlam:masterfrom
johnnyvillanueva:msys2

Conversation

@johnnyvillanueva

Copy link
Copy Markdown

Summary

This patch fixes compilation errors on modern Windows toolchains using MinGW-w64 (UCRT64) with recent GCC versions (e.g. GCC 16).

The issue occurs due to stricter type checking in Winsock APIs where getsockopt() and setsockopt() expect char * / const char * parameters, but the code passes DWORD * or int * types without explicit casting.

Problem

On modern MinGW-w64 / UCRT environments, the following compilation errors occur:

  • incompatible pointer types in getsockopt
  • incompatible pointer types in setsockopt

These were previously accepted as implicit conversions in older GCC versions but are now treated as errors under stricter type checking.

Fix

This patch adds explicit casts to match the Winsock API expectations:

  • DWORD *(char *)
  • int *(const char *)

No functional changes are introduced.

Impact

  • Fixes build failures on:

    • MSYS2 UCRT64
    • MinGW-w64 with GCC 14+
    • Windows builds using modern toolchains
  • No impact on Linux builds

  • No behavioral change in runtime logic

Tested on

  • Windows 10 / MSYS2 UCRT64
  • GCC 16.1.0
  • MinGW-w64 14.x headers

Notes

This issue appears due to stricter type enforcement in newer GCC versions combined with Winsock API signatures on Windows.

The fix is minimal and scoped to Windows builds.


@marlam

marlam commented Jun 12, 2026

Copy link
Copy Markdown
Owner

The patch does affect non-mingw builds (at the getsockopt() change). Please isolate this to mingw.

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