Mail Archives: djgpp/1996/11/28/12:38:27
Benjamin D Chambers wrote:
[...]
> ***** Warning, though, if you get a 32-bit DWord aligned wrong, you COULD
> actually end up with code that's less than half the speed it should be.
> I *believe* (I'm not sure) the way to make sure it's aligned properly is
> to use
> _PACKED_.
> ^^^^^^^^ Somebody check me here. I could be wrong...
... and you are.
__PACKED__ and #pragma packed
allow to override the builtin alignment mechanism. E.g. if you have
struct
{ char foo;
int bar;
}
a dummy will be inserted to keep bar DWORD aligned. So the
size of this struct will be 8.
OTH if you have
#pragma packed
struct
{ char foo;
int bar;
}
the size of the struct will be 5, with the penalty of bar
no longer aligned to a DWORD boundary.
--
Ciao
Tom
*************************************************************
* Thomas Demmer *
* Lehrstuhl fuer Stroemungsmechanik *
* Ruhr-Uni-Bochum *
* Universitaetsstr. 150 *
* D-44780 Bochum *
* Tel: +49 234 700 6434 *
* Fax: +49 234 709 4162 *
* Voice/Fax Box: +49 2561 91371 2056 *
* http://www.lstm.ruhr-uni-bochum.de/~demmer *
*************************************************************
- Raw text -