summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJay Satiro <[email protected]>2023-12-01 18:06:12 -0500
committerJay Satiro <[email protected]>2023-12-08 13:11:44 -0500
commit0f3f3843436c3c924e1ea2fe949c9ec51c3a6d2f (patch)
tree277954ec01cb67bc0a93d26302df4fe6b01fa163
parent7c992dd9f89ee219e7f3395211b8f7bdfebc35c3 (diff)
build: fix Windows ADDRESS_FAMILY detection
- Include winsock2.h for Windows ADDRESS_FAMILY detection. Prior to this change cmake detection didn't work because it included ws2def.h by itself, which is missing needed types from winsock2.h. Prior to this change autotools detection didn't work because it did not include any Windows header. In both cases libcurl would fall back on unsigned short as the address family type, which is the same as ADDRESS_FAMILY. Co-authored-by: Viktor Szakats Closes https://github.com/curl/curl/pull/12441
-rw-r--r--CMakeLists.txt2
-rw-r--r--configure.ac8
2 files changed, 9 insertions, 1 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 4042f001ba..c0abc284db 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1266,7 +1266,7 @@ set(HAVE_SA_FAMILY_T ${HAVE_SIZEOF_SA_FAMILY_T})
set(CMAKE_EXTRA_INCLUDE_FILES "")
if(WIN32)
- set(CMAKE_EXTRA_INCLUDE_FILES "ws2def.h")
+ set(CMAKE_EXTRA_INCLUDE_FILES "winsock2.h")
check_type_size("ADDRESS_FAMILY" SIZEOF_ADDRESS_FAMILY)
set(HAVE_ADDRESS_FAMILY ${HAVE_SIZEOF_ADDRESS_FAMILY})
set(CMAKE_EXTRA_INCLUDE_FILES "")
diff --git a/configure.ac b/configure.ac
index d9b396376d..d26a183f56 100644
--- a/configure.ac
+++ b/configure.ac
@@ -3473,6 +3473,14 @@ AC_CHECK_TYPE(sa_family_t,
AC_DEFINE(CURL_SA_FAMILY_T, ADDRESS_FAMILY, [IP address type in sockaddr]),
AC_DEFINE(CURL_SA_FAMILY_T, unsigned short, [IP address type in sockaddr]),
[
+#ifdef HAVE_WINDOWS_H
+#ifndef WIN32_LEAN_AND_MEAN
+#define WIN32_LEAN_AND_MEAN
+#endif
+#ifdef HAVE_WINSOCK2_H
+#include <winsock2.h>
+#endif
+#endif
#ifdef HAVE_SYS_SOCKET_H
#include <sys/socket.h>
#endif