Re: [OT] Re: Bug#169450: wrong assumption on char signedness
[Emile van Bergen]
> I agree, but I'm willing to bet that assuming sizeof(char) is 1 is more
> portable today than assuming stdint.h is available.
Actually, 1 == sizeof(char is defined in the ANSI C standard:
6.3.3.4 The sizeof operator
[...]
2 The sizeof operator yields the size (in bytes) of its operand,
which may be an expression or the parenthesized name of a type.
[...]
3 When applied to an operand that has type char, unsigned char or
signed char, (or a qualified version thereof) the result is 1.
sizeof() always give sizes in multiples of sizeof(char). It do not
say anything about the number of bits storable in type char. The
definition of bytes is given earlier in the standard:
3.4 Byte
1 The unit of data storage large enough to hold any member of the
basic character set of the execution environemnt. It shall be
possible to express the address of each individual byte of an
object uniquely. A byte is composed of a contiguous sequence of
bits, the number of which is implementation-defined. The list
significant bit is called the low-order bit; the most significant
bit is called the high-order bit.
Reply to: