diff --git a/client/TracyProfiler.cpp b/client/TracyProfiler.cpp index 3a40b109..6384ae30 100644 --- a/client/TracyProfiler.cpp +++ b/client/TracyProfiler.cpp @@ -928,7 +928,7 @@ enum { BulkSize = TargetFrameSize / QueueItemSize }; Profiler::Profiler() : m_timeBegin( 0 ) - , m_mainThread( GetThreadHandleImpl() ) + , m_mainThread( detail::GetThreadHandleImpl() ) , m_epoch( std::chrono::duration_cast( std::chrono::system_clock::now().time_since_epoch() ).count() ) , m_shutdown( false ) , m_shutdownManual( false ) diff --git a/common/TracySystem.hpp b/common/TracySystem.hpp index db8c61a6..cdb051d7 100644 --- a/common/TracySystem.hpp +++ b/common/TracySystem.hpp @@ -23,7 +23,8 @@ extern "C" __declspec(dllimport) unsigned long __stdcall GetCurrentThreadId(void namespace tracy { -#ifdef TRACY_ENABLE +namespace detail +{ static inline uint64_t GetThreadHandleImpl() { #ifdef _WIN32 @@ -38,13 +39,20 @@ static inline uint64_t GetThreadHandleImpl() return uint64_t( pthread_self() ); #endif } +} -const thread_local auto s_threadHandle = GetThreadHandleImpl(); +#ifdef TRACY_ENABLE +const thread_local auto s_threadHandle = detail::GetThreadHandleImpl(); static inline uint64_t GetThreadHandle() { return s_threadHandle; } +#else +static inline uint64_t GetThreadHandle() +{ + return detail::GetThreadHandleImpl(); +} #endif void SetThreadName( std::thread& thread, const char* name );