Skip to content

Fix mingw32 build: cast setsockopt optval to const char *#23

Merged
fjtrujy merged 1 commit into
masterfrom
fix/mingw32-setsockopt-cast
May 11, 2026
Merged

Fix mingw32 build: cast setsockopt optval to const char *#23
fjtrujy merged 1 commit into
masterfrom
fix/mingw32-setsockopt-cast

Conversation

@fjtrujy
Copy link
Copy Markdown
Member

@fjtrujy fjtrujy commented May 11, 2026

Summary

  • PR Enable TCP_NODELAY #22 added a setsockopt(..., TCP_NODELAY, &one, sizeof(one)) call that breaks the mingw32 build because Winsock's setsockopt prototype takes const char *optval (not const void * like POSIX).
  • Adds a (const char *) cast — harmless on POSIX, required on Windows.

This is what currently fails CI on windows-latest in the ps2dev meta build:

src/ps2link.c:61:58: error: passing argument 4 of 'setsockopt' from incompatible pointer type [-Wincompatible-pointer-types]
   61 |     setsockopt(request_socket, IPPROTO_TCP, TCP_NODELAY, &one, sizeof(one));
note: expected 'const char *' but argument is of type 'int *'
make[1]: *** [Makefile.mingw32:26: obj/ps2link.o] Error 1

Test plan

  • CI green on Linux/macOS (unchanged behavior — cast is a no-op on POSIX where optval is const void *)
  • CI green on Windows / mingw32

🤖 Generated with Claude Code

On Windows, the Winsock setsockopt prototype takes `const char *optval`,
not `const void *` like POSIX. Passing `&one` (int *) breaks the mingw32
build with -Wincompatible-pointer-types. Cast to (const char *) so it
compiles on both POSIX and Winsock.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@fjtrujy fjtrujy merged commit f8b69fd into master May 11, 2026
11 checks passed
@fjtrujy fjtrujy deleted the fix/mingw32-setsockopt-cast branch May 11, 2026 13:35
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.

1 participant