From: "John M. Aldrich" Newsgroups: comp.os.msdos.djgpp Subject: Re: attribute packed?? Date: Thu, 19 Sep 1996 23:11:56 -0700 Organization: Three pounds of chaos and a pinch of salt Lines: 34 Message-ID: <324235AC.2CB3@cs.com> References: Reply-To: fighteer AT cs DOT com NNTP-Posting-Host: ppp202.cs.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit To: Lennart Steinke To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp 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: | --------------------------------------------------------------------------