Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmake: fix Windows ADDRESS_FAMILY detection #12441

Closed
wants to merge 1 commit into from

Conversation

jay
Copy link
Member

@jay jay commented Dec 1, 2023

  • Include winsock2.h instead of ws2def.h for the size detection.

winsock2.h includes ws2def.h after defining needed types.

Prior to this change libcurl would fall back on unsigned short as the address family type, which is the same as ADDRESS_FAMILY.

Closes #xxxx

@jay jay added the cmake label Dec 1, 2023
@github-actions github-actions bot added the build label Dec 1, 2023
@vszakats
Copy link
Member

vszakats commented Dec 2, 2023

This patch fixes it for autotools:

--- 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

- 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 #xxxx
@bagder bagder added the Windows Windows-specific label Dec 2, 2023
@jay jay closed this in 0f3f384 Dec 8, 2023
@jay jay deleted the cmake_fix_address_family branch December 8, 2023 18:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

Successfully merging this pull request may close these issues.

3 participants