代码之家  ›  专栏  ›  技术社区  ›  theEpsilon

C本原能比空*宽吗?

  •  0
  • theEpsilon  · 技术社区  · 4 年前

    我知道 void*

    2 回复  |  直到 4 年前
        1
  •  4
  •   John Bollinger    4 年前

    我还想知道,通过casting,它是否可以容纳数组或结构之外的任何东西,即原语和并集。这是C[…]担保吗?

    不,不是。作为反例,对于32位CPU,指针在C实现中通常是32位宽, * 但C需要类型 long long int 至少64位宽。 C对任何算术类型的大小都没有上界,对任何指针类型的大小也没有(显式)下界,因此原则上,甚至 short 可能比 void *


    * 例如, GCC uses the pointer representation specified by the target application binary interface (ABI) defines the size of an address as 4 bytes .

    根据当前C语言标准第5.2.4.2.1/1段,类型为 双长整型 必须至少 9223372036854775807 63 至少需要64位。