Are these sizes guaranteed?

0118

No, the sizes of short, int, and long in C++ are not guaranteed to be the same across all platforms. The C++ standard specifies minimum sizes for these types:

  • short must be at least 16 bits.
  • int must be at least 16 bits.
  • long must be at least 32 bits.

However, the actual sizes can vary depending on the compiler and the architecture of the system. To ensure portability, it's often recommended to use fixed-width integer types from the <cstdint> header, such as int16_t, int32_t, int64_t, etc., which provide guaranteed sizes.

0 Comments

no data
Be the first to share your comment!