Skip to content

Commit 3fae5f1

Browse files
authored
osx: fix inconsistent use of the macro TARGET_OS_OSX (#2222)
* osx: fix inconsistent use of the macro `TARGET_OS_OSX` Fixed the build error on iOS: ``` httplib.h:3583:3: error: unknown type name 'CFStringRef' 870 | CFStringRef hostname_ref = CFStringCreateWithCString( ``` Note, `TARGET_OS_OSX` is defined but is 0 when `TARGET_OS_IOS` is 1, and vise versa. Hence, `TARGET_OS_MAC` should have been used, that is set to 1 for the both targets. * improve: non-blocking getaddrinfo() for all mac target variants `TARGET_OS_MAC` should have been used, that is set to 1 for all other targets: OSX, IPHONE (IOS, TV, WATCH, VISION, BRIDGE), SIMULATOR, DRIVERKIT.
1 parent fe7fe15 commit 3fae5f1

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

httplib.h

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,7 @@ using socket_t = int;
308308

309309
#if defined(CPPHTTPLIB_USE_NON_BLOCKING_GETADDRINFO) || \
310310
defined(CPPHTTPLIB_USE_CERTS_FROM_MACOSX_KEYCHAIN)
311-
#if TARGET_OS_OSX
311+
#if TARGET_OS_MAC
312312
#include <CFNetwork/CFHost.h>
313313
#include <CoreFoundation/CoreFoundation.h>
314314
#endif
@@ -332,7 +332,7 @@ using socket_t = int;
332332
#endif // _WIN32
333333

334334
#if defined(CPPHTTPLIB_USE_CERTS_FROM_MACOSX_KEYCHAIN)
335-
#if TARGET_OS_OSX
335+
#if TARGET_OS_MAC
336336
#include <Security/Security.h>
337337
#endif
338338
#endif // CPPHTTPLIB_USE_NON_BLOCKING_GETADDRINFO
@@ -3578,7 +3578,7 @@ inline int getaddrinfo_with_timeout(const char *node, const char *service,
35783578
}
35793579

35803580
return ret;
3581-
#elif defined(TARGET_OS_OSX)
3581+
#elif TARGET_OS_MAC
35823582
// macOS implementation using CFHost API for asynchronous DNS resolution
35833583
CFStringRef hostname_ref = CFStringCreateWithCString(
35843584
kCFAllocatorDefault, node, kCFStringEncodingUTF8);
@@ -6258,8 +6258,7 @@ inline bool load_system_certs_on_windows(X509_STORE *store) {
62586258

62596259
return result;
62606260
}
6261-
#elif defined(CPPHTTPLIB_USE_CERTS_FROM_MACOSX_KEYCHAIN) && \
6262-
defined(TARGET_OS_OSX)
6261+
#elif defined(CPPHTTPLIB_USE_CERTS_FROM_MACOSX_KEYCHAIN) && TARGET_OS_MAC
62636262
template <typename T>
62646263
using CFObjectPtr =
62656264
std::unique_ptr<typename std::remove_pointer<T>::type, void (*)(CFTypeRef)>;
@@ -11008,8 +11007,7 @@ inline bool SSLClient::load_certs() {
1100811007
#ifdef _WIN32
1100911008
loaded =
1101011009
detail::load_system_certs_on_windows(SSL_CTX_get_cert_store(ctx_));
11011-
#elif defined(CPPHTTPLIB_USE_CERTS_FROM_MACOSX_KEYCHAIN) && \
11012-
defined(TARGET_OS_OSX)
11010+
#elif defined(CPPHTTPLIB_USE_CERTS_FROM_MACOSX_KEYCHAIN) && TARGET_OS_MAC
1101311011
loaded = detail::load_system_certs_on_macos(SSL_CTX_get_cert_store(ctx_));
1101411012
#endif // _WIN32
1101511013
if (!loaded) { SSL_CTX_set_default_verify_paths(ctx_); }

0 commit comments

Comments
 (0)