Mail Archives: djgpp/1996/09/20/05:54:33
Lennart Steinke wrote:
>
> Hi!
>
> Could someone tell me what __attribute__, and
> esp. the packed option of it does, and why it's
> neccassary to use them?
I recommend that you download the DJGPP Frequently Asked Questions
List from the following URL:
ftp://ftp.simtel.net/pub/simtelnet/gnu/djgpp/v2/faq201b.zip
The part relevant to __attribute__ and why it is needed is section 22.9.
In brief: DJGPP is a 32-bit compiler. In a 32-bit operating system
it is inefficient to access memory regions that are not "aligned", i.e.,
that start on a 2- or 4-byte boundary. Thus, all variables and
structures in gcc (and thus DJGPP) are aligned automatically by default.
__attribute__((packed)) is a GNU C extension to ANSI C which allows you
to "turn off" this automatic alignment and squeeze structures into the
minimum space possible. Further documentation can be found in the info
files for gcc (type: info gcc "C Extensions" "Variable Attributes").
Note that punctuation and capitalization are important!
--
--------------------------------------------------------------------------
| John M. Aldrich, aka Fighteer I | fighteer AT cs DOT com
|
| Plan: To find ANYONE willing to | http://www.cs.com/fighteer
|
| play Descent 2 on DWANGO! | Tagline: <this space for rent>
|
--------------------------------------------------------------------------
- Raw text -