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

前端 未结 24 2293
无人及你
无人及你 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:52

    The C++ Standard says it like this:

    3.9.1, §2:

    There are five signed integer types : "signed char", "short int", "int", "long int", and "long long int". In this list, each type provides at least as much storage as those preceding it in the list. Plain ints have the natural size suggested by the architecture of the execution environment (44); the other signed integer types are provided to meet special needs.

    (44) that is, large enough to contain any value in the range of INT_MIN and INT_MAX, as defined in the header .

    The conclusion: It depends on which architecture you're working on. Any other assumption is false.

提交回复
热议问题