Python c_ulong 类型在 macOS 上是 64 位
Python c_ulong type is 64 bits on macOS
在 macOS Python 上,c_ulong
类型似乎是 64 位,而不是 Windows 上的 32 位。根据我在 google 搜索中找到的内容,基于此 post:Is Python's ctypes.c_long 64 bit on 64 bit systems?
看起来是因为macOS的内存模型。有什么解决办法吗?
就像你在写 C,如果你知道你特别需要一个 32 位无符号整数,你不应该使用 c_ulong
,而是 ctypes.c_uint32
。这样无论你在哪个平台上,你都可以确保它是 32 位的。
在 macOS Python 上,c_ulong
类型似乎是 64 位,而不是 Windows 上的 32 位。根据我在 google 搜索中找到的内容,基于此 post:Is Python's ctypes.c_long 64 bit on 64 bit systems?
看起来是因为macOS的内存模型。有什么解决办法吗?
就像你在写 C,如果你知道你特别需要一个 32 位无符号整数,你不应该使用 c_ulong
,而是 ctypes.c_uint32
。这样无论你在哪个平台上,你都可以确保它是 32 位的。