Is the sizeof(some pointer) always equal to four?

前端 未结 17 1394
温柔的废话
温柔的废话 2020-11-22 11:49

For example: sizeof(char*) returns 4. As does int*, long long*, everything that I\'ve tried. Are there any exceptions to this?

17条回答
  •  半阙折子戏
    2020-11-22 12:37

    Just for completeness and historic interest, in the 64bit world there were different platform conventions on the sizes of long and long long types, named LLP64 and LP64, mainly between Unix-type systems and Windows. An old standard named ILP64 also made int = 64-bit wide.

    Microsoft maintained LLP64 where longlong = 64 bit wide, but long remained at 32, for easier porting.

    Type           ILP64   LP64   LLP64
    char              8      8       8
    short            16     16      16
    int              64     32      32
    long             64     64      32
    long long        64     64      64
    pointer          64     64      64
    

    Source: https://stackoverflow.com/a/384672/48026

提交回复
热议问题