Is Python's ctypes.c_long 64 bit on 64 bit systems?

前端 未结 4 834
囚心锁ツ
囚心锁ツ 2020-12-19 05:20

In C, long is 64 bit on a 64 bit system. Is this reflected in Python\'s ctypes module?

4条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-19 06:09

    Actually no.

    On a Windows 64-bit system, long is 32 bits.

    Python 3.1.2 (r312:79149, Mar 20 2010, 22:55:39) [MSC v.1500 64 bit (AMD64)] on win32
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import ctypes
    >>> ctypes.c_long(2**31)
    c_long(-2147483648)
    >>> ctypes.c_long(2**31+1)
    c_long(-2147483647)
    >>> ctypes.c_long(2**31-1)
    c_long(2147483647)
    >>>
    

    See What is the bit size of long on 64-bit Windows?

提交回复
热议问题