|
|
coherent
bit-fields Definition bit-fields
A bit-field is a member of a structure or union that is defined
to be a cluster of bits. It provides a way to represent data
compactly. For example, in the following structure
struct example {
int member1;
long member2;
unsigned int member3 :5;
}
member3 is declared to be a bit-field that consists of five bits.
A colon `:' precedes the integral constant that indicates the
_w_i_d_t_h, or the number of bits in the bit-field. Also, the bit-
field declarator must include a type, which must be one of int,
signed int, or unsigned int.
A bit-field that is not given a name may not be accessed. Such
an object is useful as ``padding'' within an object so that it
conforms to a template designed elsewhere.
A bit-field that is unnamed and has a length of zero can be used
to force adjacent bit-fields into separate objects. For example,
in the following structure
struct example {
int member1;
int member2 :5;
int :0;
int member3 :5;
};
the zero-length bit-field forces member2 and member3 to be writ-
ten into separate objects.
Finally, it is illegal to take the address of a bit-field.
***** See Also *****
bit, bit map, byte, definitions
***** Notes *****
Because bit-fields have many implementation-specific properties,
they are not considered to be highly portable. Bit-fields use
minimal amounts of storage, but the amount of computation needed
to manipulate and access them may negate this benefit. Bit-
fields must be kept in integral-sized objects because many
machines cannot directly access a quantity of storage smaller
than a ``word'' (a word is generally used to store an int).
COHERENT Lexicon Page 1
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.