sizeof (int) == sizeof (void*)?

后端 未结 10 904
有刺的猬
有刺的猬 2020-12-03 01:50

Is there an integer type with the same size as pointer? Guaranteed on all microarchitectures?

10条回答
  •  無奈伤痛
    2020-12-03 02:39

    Usually sizeof(*void) depends on memory bus width (although not necessarily - pre-RISC AS/400 had 48-bit address bus but 64-bit pointers), and int usually is as big as CPU's general-purpose register (there are also exceptions - SGI C used 32-bit ints on 64-bit MIPS).

    So there is no guarantee.

提交回复
热议问题