Xref: news2.mv.net comp.os.msdos.djgpp:5011 From: Erik Max Francis Newsgroups: comp.os.msdos.djgpp Subject: Re: How are bool's allocated? Date: Fri, 14 Jun 1996 23:12:26 -0700 Organization: Alcyone Systems Lines: 30 Message-ID: <31C2544A.3963D6DF@alcyone.com> References: <4pp82v$qd4 AT usenet DOT rpi DOT edu> NNTP-Posting-Host: newton.alcyone.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp David J. Calvin wrote: > > In DJGPP, how is memory allocated for bool variables? Is just > 1 bit allocated, or a whole byte? If you do sizeof(bool), it > returns 1, but maybe that's just a limitation of sizeof(). > I'm planning on using a large number of bool's in a structure, > and I was wondering if it would be more efficient to declare > them all as bool's, or to use unsigned characters and use > bitwise ops to access each bit that way. Thanks for the info. All I have in front of me is _The design and evolution of C++_; it doesn't specify the size of a bool. However, it also specifies that bool is _not_ simply an enumerated type defined as enum bool { false, true }; In the current draft C++ standard, bool is a fundamental datatype with interesting implicit conversion behaviors that make it behave like one would expect. Packing Booleans as bits is easy, but it takes more than the usual amount of processor work. Usually you don't want to do this and it's worth it to waste seven extra bits to gain the extra speed. -- Erik Max Francis &tSftDotIotE && http://www.alcyone.com/max && max AT alcyone DOT com San Jose, California, U.S.A. && 37 20 07 N 121 53 38 W && the 4th R is respect H.3`S,3,P,3$S,#$Q,C`Q,3,P,3$S,#$Q,3`Q,3,P,C$Q,#(Q.#`-"C`- && 1love && folasade Omnia quia sunt, lumina sunt. && Dominion, GIGO, GOOGOL, Omega, Psi, Strategem "Out from his breast/his soul went to seek/the doom of the just." -- _Beowulf_