Difference between revisions of "C - Bit-fields2"

From EdWiki

m (1 revision)
m (1 revision imported: EdWiki -- Emsys pages from Shukra)
(No difference)

Latest revision as of 09:30, 23 June 2015

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