Wednesday, February 27, 2013

What are Bit-fields?

The variables defined with a fixed width are called bit fields. A well-known usage of bit-fields is to represent a set of bits, and/or series of bits. They are space-saving structure members. They allow integer members to be stored into memory spaces smaller than the compiler would ordinarily allow. The default integer type for a bit field is unsigned.

The declaration of a bit-field inside a structure has the form:

struct
{
  type [member_name] : width ;
};

No comments :