I am surprised to see also my C++ compiler supports __int8, __int16, __int32, and __int64; But I just see they are equivalent to char, short, int, and long long. What is the difference between them?
sizeof(__int8) == sizeof(char) == 1
sizeof(__int16) == sizeof(short) == 2
sizeof(__int32) == sizeof(int) == 4
sizeof(__int64) == sizeof(long long) == 8
The sizes of the primitive types
int,char,short,long, etc. are implementation-defined and can vary from system to system. All that you’re guaranteed is thatsizeof(char) == 1, andsizeof(char) <= sizeof(short) <= sizeof(int) <= sizeof(long).As a result, many platforms provide their own custom, non-portable types that are guaranteed to be the given sizes. For example, I am fairly confident that Microsoft guarantees that
__int8is always eight bits,__int16is always 16 bits, etc.Hope this helps!