From: zidharta AT geocities DOT com Newsgroups: comp.os.msdos.djgpp Subject: Re: what is _attribute_((packed)) ?? why DJGPP use it? Date: Tue, 03 Aug 1999 12:14:33 GMT Organization: Deja.com - Share what you know. Learn what you don't. Lines: 57 Message-ID: <7o6mf2$btp$1@nnrp1.deja.com> References: <7o5doq$gj8$1 AT nnrp1 DOT deja DOT com> <7o6831$4un$1 AT taliesin DOT netcom DOT net DOT uk> NNTP-Posting-Host: 203.109.254.63 X-Article-Creation-Date: Tue Aug 03 12:14:33 1999 GMT X-Http-User-Agent: Mozilla/4.08 [en] (Win95; I) X-Http-Proxy: 1.0 x29.deja.com:80 (Squid/1.1.22) for client 203.109.254.63 X-MyDeja-Info: XMYDJUIDsidxidzid To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com Im going to read the FAQ ... so if you think I can find this easily on the FAQ just ignore this ... as far as I know I need __attribute_((packed)) for reading bmp file ... is it always needed for reading file ... ? or is it only needed when you want to transfer file info into struct like when you read BMP file?? thanks alot for your reply Sid In article <7o6831$4un$1 AT taliesin DOT netcom DOT net DOT uk>, "Michael Stewart" wrote: > 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. > > Sent via Deja.com http://www.deja.com/ Share what you know. Learn what you don't.