From da6185ba5e4ce311c12cbcf4baa6fc8e356948a8 Mon Sep 17 00:00:00 2001 From: yuanyuanxiang <962914132@qq.com> Date: Tue, 24 Nov 2026 18:19:47 +0100 Subject: [PATCH] Fix: build the client on LP64 after the compression switch 0e20e0b started passing a local unsigned long to CompressData(), whose length parameter is ULONG& (typedef unsigned int). The two types are identical on Windows, so the Windows builds never noticed, but on LP64 (Linux x86_64, Android arm64/x86_64) unsigned long is 64 bit and the reference cannot bind, so IOCPClient.cpp fails to compile. This has blocked the Linux and Android native builds since then; the tracked linux/ghost predates the change, which is why it went unnoticed. Declare the length as ULONG and cast compressBound/ZSTD_compressBound accordingly. Packet lengths are bounded by the wire protocol and the type is byte-for-byte the same as before on Windows. Verified: the Linux Release build (WSL, out-of-source) compiles with both the zstd 1.5.7 and 1.6.0 headers; the Android debug APK builds for arm64-v8a and armeabi-v7a with IOCPClient.cpp actually recompiled. Co-Authored-By: deepseek-flash --- client/IOCPClient.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/client/IOCPClient.cpp b/client/IOCPClient.cpp index 3ce0848..45b0536 100644 --- a/client/IOCPClient.cpp +++ b/client/IOCPClient.cpp @@ -1156,12 +1156,14 @@ BOOL IOCPClient::OnServerSending(const char* szBuffer, ULONG ulOriginalLength, P // 线缆压缩:运行期选择 zlib / zstd(默认 zstd)。zlib 用 compressBound 而不是 // 1.001n+12 —— 后者对小于约 1KB 的包会比 compressBound 少 1 字节,导致 // compress() 返回 Z_BUF_ERROR、小包(心跳 ACK、控制命令)被静默丢弃。 + // 用 ULONG(32 位)而不是 unsigned long:LP64 下 unsigned long 是 64 位, + // 绑不到 CompressData 的 ULONG&,Linux/Android arm64 会直接编译失败。 #if CLIENT_HAS_ZLIB - unsigned long ulCompressedLength = m_useZlib - ? (unsigned long)compressBound(ulOriginalLength) - : (unsigned long)ZSTD_compressBound(ulOriginalLength); + ULONG ulCompressedLength = m_useZlib + ? (ULONG)compressBound(ulOriginalLength) + : (ULONG)ZSTD_compressBound(ulOriginalLength); #else - unsigned long ulCompressedLength = (unsigned long)ZSTD_compressBound(ulOriginalLength); + ULONG ulCompressedLength = (ULONG)ZSTD_compressBound(ulOriginalLength); #endif BYTE buf[1024]; LPBYTE CompressedBuffer = ulCompressedLength>1024 ? new BYTE[ulCompressedLength] : buf;