www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1996/06/14/15:00:31

From: caldweg1 AT tipo DOT transcripts DOT com
Date: Fri, 14 Jun 96 14:53:00 est
Message-Id: <9605148347.AA834789195@tipo.transcripts.com>
To: kagel AT dg1 DOT bloomberg DOT com
Cc: lav AT video DOT yars DOT free DOT net, djgpp AT delorie DOT com, j DOT aldrich6 AT genie DOT com
Subject: Re[4]: How are bool's allocated?

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 -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019