C - Bit-fields2

From EdWiki

Revision as of 06:51, 7 March 2012 by Jshankar (Talk | contribs) (1 revision)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Bit-fields ...

  • Individual fields are referenced in the same way as other structure members.
  • Fields may be declared only as ints.
  • Fields behave like small integers, and may participate in arithmetic expressions just like other integers.
  • Fields need not be named; Unnamed fields( a colon and width only) are used for padding.
  • They are not arrays, and they do not have addresses, so the & operator can’t be applied to them.
struct tagLSR lsr;
lsr.DataReady = 1;		// to turn the bits on
Lsr.DataReady = 0;		// to turn the bits off
If( lsr.DataReady == 1) {	// to test the bit