简体   繁体   English

Python c_ulong类型在macOS上为64位

[英]Python c_ulong type is 64 bits on macOS

It seems that on macOS Python's c_ulong type is 64 bits, instead of the 32 bits that it would be on Windows. 在macOS上,Python的c_ulong类型似乎是64位,而不是Windows上的32位。 From what I've found in my google search, based on this post: Is Python's ctypes.c_long 64 bit on 64 bit systems? 根据我在Google搜索中发现的信息,基于这篇文章: Python的ctypes.c_long在64位系统上是否为64位?

It looks like it's because of macOS's memory model. 看起来是因为macOS的内存模型。 Is there any fix for this? 有没有解决办法?

Just like if you are writing C, if you know that you specifically need a 32 bit unsigned integer, you shouldn't use c_ulong but instead ctypes.c_uint32 . 就像您正在编写C一样,如果您知道特别需要32位无符号整数,则不应使用c_ulong ,而应使用ctypes.c_uint32 This way you can ensure it will be 32 bits no matter the platform you are on. 这样,无论使用什么平台,都可以确保32位。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM