I am trying to figure out the rationale behind char
being a different type from signed char
and unsigned char
.
I found the following posts, which give some rationale but don't answer my queston:
Difference between signed / unsigned char
Part of the reason there are two dialects of "C" (those where 'char' is signed, and those where it is unsigned) is that there are some implementations where 'char' must be unsigned, and others where it must be signed.
If, in the target platform's character set, any of the characters required by standard C would map to a code higher than the maximum signed char, then 'char' must be unsigned.
If 'char' and 'short' are the same size, then 'char' must be signed.
Is char signed or unsigned by default?
early in the life of C the "standard" was flip-flopped at least twice, and some popular early compilers ended up one way and others the other
I understand that unsigned char
may be more efficient, but are there cases where signed char
is more efficient?