The reason this has been done in the past is portability. C and C ++ do not give concrete guarantees of the sizes of int , long and short , while library developers often require this.
A common solution is to define your own aliases for data types and change the definitions based on a specific platform, making sure to use a type of the appropriate size.
This problem arose in C and was addressed by adding the stdint.h header file (renamed cstdint in C ++). Enabling this header allows you to declare types int32_t , int16_t , etc. However, libraries developed before stdint.h and libraries that should be compiled on platforms that do not have this header use an old workaround.
source share