From 3f2e2629126b78c41763fcde7e2691073e402a7d Mon Sep 17 00:00:00 2001 From: Sergey Fedorov Date: Thu, 15 May 2025 19:45:36 +0800 Subject: [PATCH] Fix for Darwin when pthread_threadid_np is unavailable --- loguru.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/loguru.cpp b/loguru.cpp index 7eaadb7..7487847 100644 --- a/loguru.cpp +++ b/loguru.cpp @@ -71,7 +71,8 @@ #endif #ifdef __APPLE__ - #include "TargetConditionals.h" + #include + #include #endif // TODO: use defined(_POSIX_VERSION) for some of these things? @@ -1096,7 +1097,11 @@ namespace loguru #ifdef __APPLE__ uint64_t thread_id; - pthread_threadid_np(pthread_self(), &thread_id); + #if MAC_OS_X_VERSION_MAX_ALLOWED < 1060 || defined(__POWERPC__) + thread_id = pthread_mach_thread_np(pthread_self()); + #else + pthread_threadid_np(pthread_self(), &thread_id); + #endif #elif defined(__FreeBSD__) long thread_id; (void)thr_self(&thread_id);