Mail Archives: djgpp/1996/06/14/12:47:13
Errors-To: postmaster AT ns1
From: caldweg1 AT tipo DOT transcripts DOT com
Date: Fri, 14 Jun 96 10:25:04 est
Content-Type: text
Content-Length: 126
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;
OR
struct allbools4 {
unsigned int truth1:1;
unsigned int truth2:1;
unsigned int truth3:1;
unsigned int truth4:1;
unsigned int truth5:1;
unsigned int truth6:1;
unsigned int truth7:1;
unsigned int truth8:1;
unsigned int truth9:1;
} MyBools4;
BTW: The structure MyBools takes up 2 bytes while MyBools4 takes up 4 bytes.
--
Art S. Kagel, kagel AT quasar DOT bloomberg DOT com
A proverb is no proverb to you 'till life has illustrated it. -- John Keats
- Raw text -