cvs.gedasymbols.org/archives/browse.cgi   search  
Mail Archives: djgpp/1999/08/03/21:16:22

From: "Michael Stewart" <mike AT reggin DOT freeserve DOT co DOT uk>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: what is _attribute_((packed)) ?? why DJGPP use it?
Date: Tue, 3 Aug 1999 09:09:08 +0100
Organization: (Posted via) Netcom Internet Ltd.
Message-ID: <7o6831$4un$1@taliesin.netcom.net.uk>
References: <7o5doq$gj8$1 AT nnrp1 DOT deja DOT com>
NNTP-Posting-Host: hgty.capgemini.co.uk
X-Trace: taliesin.netcom.net.uk 933667745 5079 194.42.240.2 (3 Aug 1999 08:09:05 GMT)
X-Complaints-To: abuse AT corp DOT netcom DOT net DOT uk
NNTP-Posting-Date: 3 Aug 1999 08:09:05 GMT
X-Newsreader: Microsoft Outlook Express 4.72.3155.0
X-MimeOLE: Produced By Microsoft MimeOLE V4.72.3155.0
Lines: 29
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

zidharta AT geocities DOT com wrote in message <7o5doq$gj8$1 AT nnrp1 DOT deja DOT com>...
>I was looking at this bitmap loader source code ... and I noticed that
>he used __attribute_((packed)) ... and I dont understand what is it...
>I ve been looking at my C library help file and I couldnt find anything
>about it ...

>
>if anyone can explain to me what that is and why DJGPP need it?.. is it
>has something to do with protected mode?..


Its all in the FAQ, heres an extract:
GCC generates 32-bit code, and in that mode, there is a significant penalty
(in terms of run-time performance) for unaligned accesses, like accessing a
16-bit short which isn't aligned on a word boundary, or accessing a 32-bit
int which isn't aligned on a dword boundary.  To produce faster code, GCC
pads struct fields so that each field can be accessed without delays; this
sometimes produces struct size which is larger than the sum of the sizes of
its fields.
...
If the layout of the structure cannot be changed (e.g., when it must match
some external specification, like a block of data returned by some system
call), you can use the __attribute__((packed)) extension of GCC (See the Gcc
docs.) to prevent GCC from padding the structure fields; this will make
accesses to some of the fields slower.




- Raw text -


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