Repository navigation
Add Windows support - #87
Merged
Merged
Conversation
c-ares shipped with POSIX-only config headers, so the build failed on Windows at the first `#include <sys/socket.h>`. Make the vendored config Windows-aware and wire up the platform bits: - ares_build.h: on _WIN32 use `int` for ares_socklen_t and the Win64/Win32 ares_ssize_t, and don't pull in <sys/socket.h>. - ares_config.h: on _WIN32 defer to c-ares's bundled config-win32.h via a path relative to the header, so it resolves both when compiling the c-ares sources and when the Swift compiler builds the Clang module from the umbrella header. - CAsyncDNSResolver.h: include winsock2.h/ws2tcpip.h instead of arpa/inet.h + netdb.h on Windows, and define CARES_STATICLIB so the statically-linked c-ares API isn't marked __declspec(dllimport). - Package.swift: define CARES_STATICLIB for the c-ares sources and link ws2_32/iphlpapi/advapi32 on Windows. - DNSResolver_c-ares.swift: recreate ARES_SOCKET_BAD (INVALID_SOCKET is a cast-expression macro Swift can't import and pass inet_ntop's size argument as size_t on Windows. Enable the Windows unit-test matrix (6.1/6.2/6.3 + nightlies) in the PR workflow with the same warnings-as-errors flags as Linux.
glbrntt
approved these changes
Jul 6, 2026
glbrntt
left a comment
Contributor
There was a problem hiding this comment.
Great, thanks @jakepetroules!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
c-ares shipped with POSIX-only config headers, so the build failed on Windows at the first
#include <sys/socket.h>. Make the vendored config Windows-aware and wire up the platform bits:intfor ares_socklen_t and the Win64/Win32 ares_ssize_t, and don't pull in <sys/socket.h>.Enable the Windows unit-test matrix (6.1/6.2/6.3 + nightlies) in the PR workflow with the same warnings-as-errors flags as Linux.