www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1996/09/20/05:54:33

From: "John M. Aldrich" <fighteer AT cs DOT com>
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: <Pine DOT VUL DOT 3 DOT 91 DOT 960919114251 DOT 2058C-100000 AT zeus DOT adv-boeblingen DOT de>
Reply-To: fighteer AT cs DOT com
NNTP-Posting-Host: ppp202.cs.com
Mime-Version: 1.0
To: Lennart Steinke <steinke AT zeus DOT adv-boeblingen DOT de>
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: <this space for rent>  
|
--------------------------------------------------------------------------

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019