From: Amos Jeffries Date: Sun, 2 Jul 2023 09:33:16 +0000 (+0000) Subject: MinGW: fix winsock dependency issues (#1375) X-Git-Tag: SQUID_7_0_1~410 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=f44dcb9533b53aa17089685ea08605839bddd596;p=thirdparty%2Fsquid.git MinGW: fix winsock dependency issues (#1375) error: warning: Please include winsock2.h before windows.h Cleanup these header includes across all Squid code built for Windows. Also, detect these headers early to fix autoconf tests relying on them. --- diff --git a/acinclude/lib-checks.m4 b/acinclude/lib-checks.m4 index 53847a8161..26ebb758bd 100644 --- a/acinclude/lib-checks.m4 +++ b/acinclude/lib-checks.m4 @@ -10,8 +10,8 @@ AC_DEFUN([SQUID_CHECK_LIBIPHLPAPI],[ SQUID_STATE_SAVE(iphlpapi) LIBS="$LIBS -liphlpapi" AC_LINK_IFELSE([AC_LANG_PROGRAM([[ -#include #include +#include #include ]], [[ MIB_IPNETTABLE i; diff --git a/configure.ac b/configure.ac index df97988bab..0379371c1a 100644 --- a/configure.ac +++ b/configure.ac @@ -189,6 +189,19 @@ AS_CASE(["$squid_host_os"], [mingw],[ CFLAGS="$CFLAGS -mthreads" CXXFLAGS="$CXXFLAGS -mthreads -static-libgcc -static-libstdc++" + dnl Check for Winsock only on MinGW + SQUID_CHECK_WINSOCK_LIB + AC_CHECK_HEADERS([ws2tcpip.h winsock2.h windows.h],,,[ +#if HAVE_WS2TCPIP_H +#include +#endif +#if HAVE_WINSOCK2_H +#include +#endif +#if HAVE_WINDOWS_H +#include +#endif + ]) MINGW_LIBS="-lmingwex" AC_SUBST(MINGW_LIBS) ], @@ -2487,24 +2500,6 @@ AC_SEARCH_LIBS([__res_search],[resolv]) AC_SEARCH_LIBS([bind],[socket]) AC_SEARCH_LIBS([opcom_stack_trace],[opcom_stack]) AC_SEARCH_LIBS([yp_match], [nsl nss_nis nss_nisplus]) -dnl Check for Winsock only on MinGW, on Cygwin we must use emulated BSD socket API -AS_IF([test "x$squid_host_os" = "xmingw"],[ - SQUID_CHECK_WINSOCK_LIB - AC_CHECK_HEADERS( \ - windows.h \ - ws2tcpip.h \ - iphlpapi.h ,,,[ -#if HAVE_WINSOCK2_H -#include -#endif -#if HAVE_WINDOWS_H -#include -#endif -#if HAVE_WS2TCPIP_H -#include -#endif - ]) -]) # check that we have unix sockets SQUID_CHECK_UNIX_SOCKET diff --git a/src/icmp/Icmp4.h b/src/icmp/Icmp4.h index 7e8c12be1c..6214a916cb 100644 --- a/src/icmp/Icmp4.h +++ b/src/icmp/Icmp4.h @@ -63,12 +63,7 @@ #include "fde.h" #if _SQUID_WINDOWS_ - -#if HAVE_WINSOCK2_H -#include -#endif #include - #endif /* IP Header */ diff --git a/src/icmp/pinger.cc b/src/icmp/pinger.cc index 98af8a0b89..951c177332 100644 --- a/src/icmp/pinger.cc +++ b/src/icmp/pinger.cc @@ -57,9 +57,6 @@ #if _SQUID_WINDOWS_ -#if HAVE_WINSOCK2_H -#include -#endif #include #include "fde.h"