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:
1 parent
a25e89b220
commit
4456467c50
2 files changed
+8
-2
No files matched your search
@@ -785,7 +785,11 @@ BOOL IOCPClient::ConnectServer(const char* szServerIP, unsigned short uPort)
|
||||
// the TCP stream and prevent any complete command from being delivered.
|
||||
// SAFE_CLOSE_HANDLE and CloseHandle are no-ops on Android, so the value
|
||||
// is never dereferenced as a kernel handle.
|
||||
m_hWorkThread = reinterpret_cast<HANDLE>(static_cast<uintptr_t>(id));
|
||||
// POSIX 下这个值只当「线程已存在」的非空标志用,从不反向解引用。
|
||||
// 不能用 static_cast<uintptr_t>(id):macOS 的 pthread_t 是
|
||||
// _opaque_pthread_t*(Linux/Android 是整型),指针经整型中转是非法的。
|
||||
// reinterpret_cast 对两种形态都成立(整型→指针 / 指针→指针)。
|
||||
m_hWorkThread = reinterpret_cast<HANDLE>(id);
|
||||
} else {
|
||||
// pthread_create 直接返回错误码(不经 errno):EAGAIN(35)/EPERM(1) 基本就是
|
||||
// 进程/用户的线程数到顶。这条路径原本完全静默——连接看起来「成功」了,
|
||||
|
||||
Reference in new issue
Block a user