From: Thomas Demmer Newsgroups: comp.os.msdos.djgpp Subject: Re: Optimization Date: Thu, 28 Nov 1996 14:59:04 +0100 Organization: Lehrstuhl fuer Stroemungsmechanik Lines: 41 Message-ID: <329D9AA8.167E@LSTM.Ruhr-UNI-Bochum.De> References: <19961128 DOT 160329 DOT 4455 DOT 4 DOT chambersb AT juno DOT com> NNTP-Posting-Host: bvb.lstm.ruhr-uni-bochum.de 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 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 * *************************************************************