News for hackers. Stuff that matters.
Re:C Programming Guidelines by nitrogen on Wednesday September 02, 2015 @03:12AM (#10157823)
CHAR_BIT must be at least 8 bits, but is not a "byte" as used by the original comment. The C standard defines "byte" differently from current common usage. To get exactly 8 bits of the desired signedness, which may not be possible on systems with CHAR_BIT greater than 8, one must use [u]int8_t.

----

From a draft version of the C standard:

The typedef name intN_t designates a signed integer type with width N , no padding bits, and a two’s complement representation. Thus, int8_t denotes such a signed integer type with a width of exactly 8 bits.

The typedef name uintN_t designates an unsigned integer type with width N and no padding bits. Thus, uint24_t denotes such an unsigned integer type with a width of exactly 24 bits.

These types are optional. However, if an implementation provides integer types with widths of 8, 16, 32, or 64 bits, no padding bits, and (for the signed types) that have a two’s complement representation, it shall define the corresponding typedef names.

Re:C Programming Guidelines by Tomte on Wednesday September 02, 2015 @03:39AM (#10157899)
Yes, exactly. Why are you telling me this?

If we're talking about C, we should use the technical definition of "byte" as used by C.

Everywhere else, sure, let's view byte as a 8 bit entity. That's so predominant that everything else would be nit-picking.

But not in the context of the C language.

Re:C Programming Guidelines by nitrogen on Wednesday September 02, 2015 @12:20PM (#10160286)
I was commenting more for the benefit of the original commenter who said there is no "byte" type.
Re:C Programming Guidelines by caf on Wednesday September 02, 2015 @03:30AM (#10157875)
int8_t and uint8_t are definitely not possible on systems with CHAR_BIT greater than 8.

(From 6.2.6.1: Values stored in non-bit-field objects of any other object type consist of n × CHAR_BIT bits, where n is the size of an object of that type, in bytes.)