In fact, until you have a reason to choose something other than int
, you must choose it.
If you want to use a char
, use it. It always has 1 byte. And I doubt that I will find an active platform that the byte is different from 8. Certainly none is less than 7, or standard C cannot work, after all it needs to be able to represent at least 95 different characters. And it would be the only case where the int_fast8_t
would not be a char
, but in practice this does not exist.
The question says that int_least8_t
is always a char
. It can be used to give a different semantics and indicate more clearly that there is a char
and yes an integer with at least 8 bits. In practice changes nothing.
Want to choose for what? Without a problem definition, any solution can be nice.
If you are going to develop for several platforms and need to ensure that in all have the best possible performance for the integer of at least 8 bits will almost always be a int
. I would not "waste time" and wear something like this if it is not proven that it is absolutely necessary.
C and C++ require the int
has at least 16 bits and cannot be larger than the long int
. If it actually has 10 bits, the implementation is not standard, then anything can happen according to the will of the implementor, but in practice it is no longer the C or C language++.
In theory each language implementer can put whatever they want into these types for each platform that it manages code, provided it obeys the rule of specification, and is within the standard. When in doubt they will choose the int
which is quite common but not required to be the word size of the processor.
Actually the question is more imaginary than theoretical.
Is there any platform in use with 10-bit byte?
– Maniero
I cannot say. I know few architectures. The question is more theoretical than practical. I am curious to know the rules that are involved in the whole decision-making of the compiler.
– jlHertel