Chuck Guzis wrote:
Not the same at all. I don't believe that in C I
can declare:
bit anything[60000];
Standard C provides one predefined data type that is semantically a bit,
which is _Bool. (Most people use the bool macro in <stdbool.h>, which
expands to _Bool.) Any non-zero value when converted to _Bool becomes 1.
The standard says that an object declared as type _Bool is large enough
to store the values 0 and 1 (ISO/IEC 9899:1999 section 6.2.5 paragraph
2). This suggests that it may be as small as a single bit. However,
"Except for bit-fields, objects are composed of contiguous sequences of
one or more bytes" (section 6.2.6.1 paragraph 2), which has the perhaps
unfortunate consequence that a _Bool can't be stored as a single bit
except in a bitfield.
It would have been nice if C had offered a packed array type, such that
in a packed array of _Bool each component would occupy only one bit of
storage. The difficulty that arises from that is that you can't have a
C pointer to one of those bits (unless a new kind of C pointer is
invented), and that it breaks the semantics of the indexing (square
bracket) and dereferencing (unary *) operators. That's not to say that
it couldn't be done, just that it definitely will complicate the
language definition significantly. One could argue either way about
whether that complication is justifiable.