Re: bool vs. BOOL
- From: "David Webber" <dave@xxxxxxxxxxxxxxxxxxx>
- Date: Wed, 17 Jan 2007 12:21:56 -0000
"MrAsm" <invalid@xxxxxxxxxxx> wrote in message
On Wed, 17 Jan 2007 07:12:53 -0000, "David Webber"
As someone paranoid about structure packing and byte boundaries in
Dave: what is this?
Do you mean that if structures are 4-bytes aligned, the code is more
efficient (because PC architectures are 32 bits? But on 64 bits
I probably really meant paranoid :-) It isn't really a question of
efficiency - more control-freakery :-)
I use bit fields a *lot*. If I need packing bit fields I put them in
explicitly so that bit fields do not cross 2 byte boundaries (or 1byte if I
can help it). I tend to set 2 byte boundaries for packing.
More generally, I do not like invisible packing bytes anywhere, and tend
always to put a "reserved" variable in so that I can see the whole structure
as it will be in memory (and zero unused elements explicitly in the
constructor). It is a habit I have got into.
There are some very good underlying reasons.
The main one is that my music software has large arrays of small
elements representing notes, bar-lines etc, and that in a new version these
may acquire more bit fields (in place of hitherto reserved ones) without
changing the size of the structure. They are read in as just so many bytes
from the data file, and when reading an old format file, I can do it in the
sure knowledge that the new bit fields will be read in as zero.
It is a paranoia which has served me well in code maintenance an development
over nearly two decades! :-)
The result is that I would never (in 32 bit systems) write
It just sort of offends my sense of what is right to do it the first way :-)
It might be like not walking under ladders, but I suspect we all have our
comfort zones :-)
Author MOZART the music processor for Windows -
For discussion/support see
- Re: bool vs. BOOL
- From: Tom Serface
- Re: bool vs. BOOL
- Prev by Date: api functions(from non mfc dll) won't work
- Next by Date: Re: SDI -To display a control above the status bar
- Previous by thread: Re: bool vs. BOOL
- Next by thread: Re: bool vs. BOOL