Skip to content

Commit e8a70f7

Browse files
committed
Detect if afunix.h exists
Signed-off-by: Piotr Stankiewicz <[email protected]>
1 parent fd324e1 commit e8a70f7

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

httplib.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,8 +192,11 @@ using ssize_t = long;
192192
#include <winsock2.h>
193193
#include <ws2tcpip.h>
194194

195+
#if __has_include(<afunix.h>)
195196
// afunix.h uses types declared in winsock2.h, so has to be included after it.
196197
#include <afunix.h>
198+
#define HAVE_AFUNIX 1
199+
#endif
197200

198201
#ifndef WSA_FLAG_NO_HANDLE_INHERIT
199202
#define WSA_FLAG_NO_HANDLE_INHERIT 0x80
@@ -3551,6 +3554,7 @@ socket_t create_socket(const std::string &host, const std::string &ip, int port,
35513554
hints.ai_flags = socket_flags;
35523555
}
35533556

3557+
#if !defined(_WIN32) || defined(HAVE_AFUNIX)
35543558
if (hints.ai_family == AF_UNIX) {
35553559
const auto addrlen = host.length();
35563560
if (addrlen > sizeof(sockaddr_un::sun_path)) { return INVALID_SOCKET; }
@@ -3595,6 +3599,7 @@ socket_t create_socket(const std::string &host, const std::string &ip, int port,
35953599
}
35963600
return sock;
35973601
}
3602+
#endif
35983603

35993604
auto service = std::to_string(port);
36003605

0 commit comments

Comments
 (0)