Monday 30 April 2012

Bit Field


In addition to declarators for members of a structure or union, a structure declarator can also be a specified number of bits, called a "bit field." Its length is set off from the declarator for the field name by a colon. A bit field is interpreted as an integral type.
Although languages such as C or C++ have built-in support for bit fields, these can be still implemented manually, even in languages lacking native bit field native bitfield support. It suffices to have a set of integer constants, to which each a power of two is assigned, that semantically associates each individual bit with its respective semantic state.
struct-declarator:
declarator
type-specifier declarator opt constant-expression
The constant-expression specifies the width of the field in bits. The type-specifier for the declarator must be unsigned intsigned int, or int, and the constant-expression must be a nonnegative integer value. If the value is zero, the declaration has no declarator.


You may like the following posts:
User Defined Data types:

         Enum or Enumerations

No comments:

Post a Comment