Skip to content

Fix Windows/MinGW Compatibility and Socket Type Mismatches#28

Open
jolavillette wants to merge 1 commit intoi2p:masterfrom
jolavillette:FixWindowsCompilation
Open

Fix Windows/MinGW Compatibility and Socket Type Mismatches#28
jolavillette wants to merge 1 commit intoi2p:masterfrom
jolavillette:FixWindowsCompilation

Conversation

@jolavillette
Copy link

@jolavillette jolavillette commented Feb 22, 2026

Note to the maintainer: these changes are required to successfully compile RetroShare for Windows/MinGW

Description
This PR addresses several compilation and runtime issues encountered when building libsam3 on Windows using the MinGW toolchain.

Key Changes:

Header Inclusion Order: Swapped winsock2.h and windows.h inclusion order to prevent macro redefinition conflicts and ensure proper socket API availability.

Socket API Compatibility:
Defined ioctl as ioctlsocket on Win32 platforms.
Added explicit type casts (const char* and char*) for parameters in setsockopt and getsockopt calls, as required by the Windows Sockets API.

Type Safety: Updated sam3aBytesAvail to use u_long for the FIONREAD command on Windows, ensuring correct behavior when checking for available data on a socket.

Portability: Ensured that MSG_NOSIGNAL and SHUT_RDWR are correctly defined or handled for the Windows environment.

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