Re: Bitfields, yet again...

From: Pink Floyd (floyd@south.mit.edu)
Date: 11/27/95


   Pink Floyd writes:
   > Well, there was one limit on bitfields that I was not aware of that has
   > helped me decide about changing to bitfields.  They can not cross 
   > integer boundaries!  That is, I can only have 32 fields in any bitfield
   > structure.  I thought it was unlimited, which would have been the
   > overwhelming reason to switch to them.  I guess I'll stick with bitvectors.

   Whoa.  Bitfields not being able to cross integer boundaries means that
   you can't have a single bitfield that contains more bits than an int.  I
   don't think that there is any intrinsic limit to the number of bitfields
   you can have in a structure.

My C book sucks, I think.  So lemme get this straight.  Any particular field
can not cross an integer boundary, like this:
struct bitfield_struct  {
  unsigned a : 25;
  unsigned b : 10; /* this one's forbidden, it contains an integer boundary */
};

but this is not a problem:
struct bitfield_struct {
  unsigned a: 30;
  unsigned b: 1;
  unsigned c: 1;
  unsigned d: 1;
 ...
};
 and that, in fact, I could have a bitfield structure with 100 entries, as 
long as no particular entry crosses the integer boundary?
Assuming this is the case, can I safely assume that I can write a bitfield
structure to my player file and then read it in later?



This archive was generated by hypermail 2b30 : 12/07/00 PST