As I understand it, the C specification says that type int
is supposed to be the most efficient type on target platform that contains at least 16 bits.
Isn't that exactly what the C99 definition of int_fast16_t
is too?
Maybe they put it in there just for consistency, since the other int_fastXX_t
are needed?
Update
To summarize discussion below:
Example: MSVC on x86-64 has a 32-bit int, even on 64-bit systems. MS chose to do this because too many people assumed int would always be exactly 32-bits, and so a lot of ABIs would break. However, it's possible that int_fast32_t would be a 64-bit number if 64-bit values were faster on x86-64. (Which I don't think is actually the case, but it just demonstrates the point)
int_fast16_t
is guaranteed to be the fastest int with a size of at least 16 bits. int
has no guarantee of its size except that:
sizeof(char) = 1 and sizeof(char) <= sizeof(short) <= sizeof(int) <= sizeof(long).
And that it can hold the range of -32767 to +32767.
(7.20.1.3p2) "The typedef name
int_fastN_t
designates the fastest signed integer type with a width of at least N. The typedef nameuint_fastN_t
designates the fastest unsigned integer type with a width of at least N."