Mail Archives: djgpp/1996/06/14/15:00:31
Art Kagel writes in response to
I had this problem - porting code that had bools to djgpp -
v2. Use unsigned name : 1; and life is good.
Right but, IMHO, the compiler will allocate a long to hold this bit and I do
not know if multiple declarations will be placed into a single word unless the
bit fields are all in the same struct. Putting all of the bit fields into a
struct, however, does place the fields in contiguous locations, ie 32bits of
bit fields in the first word with the 33rd bit in the next word, assuming no
single field spans the word boundary. Hence:
struct allbools {
unsigned char truth1:1;
unsigned char truth2:1;
unsigned char truth3:1;
unsigned char truth4:1;
unsigned char truth5:1;
unsigned char truth6:1;
unsigned char truth7:1;
unsigned char truth8:1;
unsigned char truth9:1;
} MyBools;
etc
-
Art S. Kagel, kagel AT quasar DOT bloomberg DOT com
- You are absolutely right. A detail I neglected to mention, all the
bools were put into a structure, otherwise each takes up
unsigned space. I was misfocused on the editor part of the
solution.
- Raw text -