[vlc-devel] [PATCH] core: ensure getsockopt/setsockopt use the proper pointer size on Windows

Steve Lhomme robux4 at ycbcr.xyz
Tue Jul 7 08:29:03 CEST 2020

Unlike most UNIX calls [1] on Windows many calls expect a BOOL instead of an
int [2]. It should be the same size, but make sure this is the case when

We don't seem to use any of the options with a DWORD, LINGER or Service
Provider values.

[1] https://www.man7.org/linux/man-pages/man7/socket.7.html
[2] https://docs.microsoft.com/en-us/windows/win32/api/winsock/nf-winsock-setsockopt
 src/network/io.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/src/network/io.c b/src/network/io.c
index 5b17e67f6b7..5285edc169a 100644
--- a/src/network/io.c
+++ b/src/network/io.c
@@ -74,6 +74,10 @@ int net_Socket (vlc_object_t *p_this, int family, int socktype,
         return -1;
+#ifdef _WIN32
+    // Windows expects a BOOL for some getsockopt/setsockopt options
+    static_assert(sizeof(int)==sizeof(BOOL), "mismatching type for setsockopt");
     setsockopt (fd, SOL_SOCKET, SO_REUSEADDR, &(int){ 1 }, sizeof (int));
 #ifdef IPV6_V6ONLY

More information about the vlc-devel mailing list