[PATCH] wininet: Include winsock2.h before stdlib.h.

Francois Gouget fgouget at codeweavers.com
Wed Oct 2 05:33:32 CDT 2019


Otherwise winsock2.h's fd_set macros break <sys/select.h> which is
included by <time.h> on NetBSD.
Moving winsock2.h after all system includes may work too because
http.c does not (currently) use any of the fd_set APIs. But it seems
like there would be a higher risk of mixing Unix socket types from the
Unix headers with the Windows ones.
So include winsock2.h first as recommended, but then _WIN32 is defined
which causes zlib.h to use FAR which is not allowed in Wine code. So
carve out an exception for it.

Signed-off-by: Francois Gouget <fgouget at codeweavers.com>
---

Resubmitting...

 dlls/wininet/http.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/dlls/wininet/http.c b/dlls/wininet/http.c
index fc412849eb5..949a6afc9c6 100644
--- a/dlls/wininet/http.c
+++ b/dlls/wininet/http.c
@@ -29,15 +29,19 @@
 
 #include "config.h"
 
+#include "winsock2.h"
+#include "ws2ipdef.h"
+
 #include <stdlib.h>
 
 #ifdef HAVE_ZLIB
+#  undef FAR
+#  define FAR
 #  include <zlib.h>
+#  undef FAR
+#  define FAR __ONLY_IN_WINELIB(/* nothing */)
 #endif
 
-#include "winsock2.h"
-#include "ws2ipdef.h"
-
 #include <stdarg.h>
 #include <stdio.h>
 #include <time.h>
-- 
2.20.1



More information about the wine-devel mailing list