Reputation: 965
What actually belongs to the "character type" in C11 — besides char
of course?
To be more precise, the special exceptions for the character type (for example that any object can be accessed by an lvalue expression of character type — see §6.5/7 in C11 standard), to which concrete types do they apply? They seem to apply to uint8_t
and int8_t
from stdint.h
, but is this guaranteed? On the other hand gcc doesn't regard char16_t
from uchar.h
as a "character type".
Upvotes: 13
Views: 986
Reputation: 25752
Only char
, signed char
and unsigned char
1.
The types uint8_t
, int8_t
, char16_t
, or any type in the form intN_t
or charN_t
, may or may not be synonyms for a character type.
1(Quoted from: ISO/IEC 9899:201x 6.2.5 Types 15)
The three types char, signed char, and unsigned char are collectively called the character types.
Upvotes: 8
Reputation: 121387
char
, signed char
, and unsigned char
are the character types in C11. This is the same since C89.
Treating int8_t
(or uint8_t
) as a character type has many problems.
CHAR_BIT > 8
. Since they are, if they exist, typedef'ed to an existing type, you can probably get away with using int8_t
or uint8_t
as a character type in practice. But the standard doesn't guarantee anything and there's no reason to treat them as such anyway when you have the real character types.
Upvotes: 7