www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1995/07/27/13:18:21

Date: 27 Jul 1995 11:11:45 -0500 (CDT)
From: jmccawle AT cs DOT uno DOT edu (Cap'n Hardgeus)
Subject: Re: GCC/DJGPP Weirdness (structure padding stuff)
To: djgpp AT sun DOT soe DOT clarkson DOT edu

>2) Tell GCC not to pad the data.
>   To do this you need to use the "attribute" option for the declaration.
>   I don't have the source code to hand, but from memory the syntax is:
>   
>   (example struct) :
>   struct test {
>        char x __attribute__ ((PACKED));
>        int y __attribute__ ((PACKED));
>        /* etc. for all data in the struct */
>   };
>
>This ensures that all the elements of the struct are stored contiguously,
>so a fread() should word OK.

This is correct, except PACKED should be lowercase...

char x __attribute__ ((packed));

    Thanks for posting about this!  I have known about padding
for a little while, but I never knew why it existed.  Right after I read
these postings,  I figured out that this is what was wrong with my CD-Rom
library!!  I was sending structures with padding to a dos interrupt.  So 
thanks to you guys I will soon have it working.
(BTW...whoever writes the FAQ...this padding subject combined
 with sending structures to interrupts is some pretty heavy 
 stuff...howzabout adding it in?  I know its not QUITE a DJGPP thing,
 but I never dealt with it in Microsoft C (i think) )

John R. McCawley III
Cap'n Hardgeus




- Raw text -


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