Bitfield Structures

Top  Previous  Next

Tibbo C supports bitfield structures. The only limitation is that you can't use signed or unsigned long variables to store bitfields. Signed/unsigned chars and ints are OK:

 

Tibbo C:

struct flags_struct{
  signed int f1:1;
  signed int f2:2;
  signed int f3:3;
  signed int f4:4;
  signed int f5:5;
  signed int f6:1;
};
 
struct flags_struct flags;
...
if(flags_ptr->f4==-8)
  flags.f2=0;