Fix(client): build on macOS after the pthread_t cast

The macOS client failed to compile at client/IOCPClient.cpp:788:
static_cast from 'pthread_t' (aka '_opaque_pthread_t *') to 'uintptr_t'
is not allowed. Darwin defines pthread_t as a pointer, while Linux and
Android define it as an integer, so routing it through uintptr_t refused
to build there.

On POSIX the stored value is only a non-null "a worker thread exists"
marker: CloseHandle and SAFE_CLOSE_HANDLE are no-ops, and nothing ever
dereferences it. reinterpret_cast<HANDLE> accepts both shapes — integer
to pointer on Linux/Android, pointer to pointer on macOS — so the same
line now compiles everywhere. IOCPUDPClient.cpp had the identical cast
and got the same one-line change; it is not in any current build list,
but it would hit the same error if it were.

Verified with a green Linux client rebuild (integral pthread_t). Not yet
built on a real Mac.

Co-Authored-By: deepseek-flash
This commit is contained in:
yuanyuanxianganddeepseek-flash committed 2026-11-14 12:19:44 +01:00
1 parent a25e89b220
commit 4456467c50
2 files changed
+8 -2

No files matched your search

+3 -1
View File
@@ -49,7 +49,9 @@ BOOL IOCPUDPClient::ConnectServer(const char* szServerIP, unsigned short uPort)
if (ret == 0) {
m_bWorkThread = S_RUN;
m_bIsRunning = TRUE;
m_hWorkThread = reinterpret_cast<HANDLE>(static_cast<uintptr_t>(id));
// 同 IOCPClient:macOS 的 pthread_t 是 _opaque_pthread_t*,不能经
// static_cast<uintptr_t> 中转,reinterpret_cast 对整型/指针两种实现都成立。
m_hWorkThread = reinterpret_cast<HANDLE>(id);
}
#endif
}