Skip to content

Commit 308aeb1

Browse files
sasq64Jonas Minnberg
andauthored
Undefined if2ip() also on Android since getifaddrs() does not exist. (yhirose#648)
Co-authored-by: Jonas Minnberg <[email protected]>
1 parent 05d18f2 commit 308aeb1

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

httplib.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1933,7 +1933,11 @@ inline bool bind_ip_address(socket_t sock, const char *host) {
19331933
return ret;
19341934
}
19351935

1936-
#ifndef _WIN32
1936+
#if !defined _WIN32 && !defined ANDROID
1937+
#define USE_IF2IP
1938+
#endif
1939+
1940+
#ifdef USE_IF2IP
19371941
inline std::string if2ip(const std::string &ifn) {
19381942
struct ifaddrs *ifap;
19391943
getifaddrs(&ifap);
@@ -1963,7 +1967,7 @@ inline socket_t create_client_socket(const char *host, int port,
19631967
host, port, 0, tcp_nodelay, socket_options,
19641968
[&](socket_t sock, struct addrinfo &ai) -> bool {
19651969
if (!intf.empty()) {
1966-
#ifndef _WIN32
1970+
#ifdef USE_IF2IP
19671971
auto ip = if2ip(intf);
19681972
if (ip.empty()) { ip = intf; }
19691973
if (!bind_ip_address(sock, ip.c_str())) {

0 commit comments

Comments
 (0)