COHERENT manpages
This page displays the COHERENT manpage for bit-fields [Definition].
List of available manpages
Index
bit-fields -- Definition
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 width, 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 written into
separate objects.
Finally, it is illegal to take the address of a bit-field.
See Also
bit,
bit map,
byte,
Programming COHERENT,
ANSI Standard, §3.5.2.1
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).






