What does the C++ standard state the size of int, long type to be?

前端 未结 24 2280
无人及你
无人及你 2020-11-21 04:42

I\'m looking for detailed information regarding the size of basic C++ types. I know that it depends on the architecture (16 bits, 32 bits, 64 bits) and the compiler.

24条回答
  •  逝去的感伤
    2020-11-21 04:53

    For 32-bit systems, the 'de facto' standard is ILP32 — that is, int, long and pointer are all 32-bit quantities.

    For 64-bit systems, the primary Unix 'de facto' standard is LP64 — long and pointer are 64-bit (but int is 32-bit). The Windows 64-bit standard is LLP64 — long long and pointer are 64-bit (but long and int are both 32-bit).

    At one time, some Unix systems used an ILP64 organization.

    None of these de facto standards is legislated by the C standard (ISO/IEC 9899:1999), but all are permitted by it.

    And, by definition, sizeof(char) is 1, notwithstanding the test in the Perl configure script.

    Note that there were machines (Crays) where CHAR_BIT was much larger than 8. That meant, IIRC, that sizeof(int) was also 1, because both char and int were 32-bit.

提交回复
热议问题