Date: Thu, 4 May 2000 12:44:52 +0200 (MET DST) From: pad2369 Message-Id: <200005041044.MAA17219@maggiore.iperbole.bologna.it> To: Alexandre Devaure Cc: djgpp AT delorie DOT com References: <005b01bfb593$eb5b1c60$3eefa8c0 AT leroyautom DOT com> In-Reply-To: <005b01bfb593$eb5b1c60$3eefa8c0@leroyautom.com> MIME-Version: 1.0 Content-Type: text/plain Content-Transfer-Encoding: 8bit User-Agent: IMP/PHP3 Imap webMail Program 2.0.11 Sender: pad2369 AT iperbole DOT bologna DOT it Subject: Re: structures size Reply-To: djgpp AT delorie DOT com Alexandre Devaure : > Eli Zaretskii > > On Wed, 3 May 2000, Alexandre Devaure wrote: > > > > > I'd like the size of my structures is the same that in Borland C > because > my > > > program need to read a structure in flash written by a program > developed > > > under Borland C. So, I want to use the -fpack- struct option at > compilation > > > time. But it has no effect on the structure size and I need to add the > > > packed attribute on each structure. > > > > C programs or C++ programs? > > > > Can you post a short test program and its compilation command line, which > > can be used to reproduce this problem? > > > > > This is a C program : > > #include > > struct l { > uchar c; > uint o; > uint s; > }; > struct st { > struct l l; > ulong d; > uchar i; > uchar t; > ulong n; > }; > > main() > { > printf("%d\n",sizeof(struct st)); > } > > the command line is gcc -fpack-struct file.c Quoting section 22.11 of the FAQ list (v2.30): GCC 2.95.1 and 2.95.2 had bugs in their support of -fpack-struct (the bug is corrected in v2.96 and later). It seems you need to upgrade to latest gcc, otherwise you must use __attribute__((packed)) for each struct in stead of -fpack-struct on command line... ciao Giacomo --------------------------------------------------- Giacomo Degli Esposti - pad2369 AT iperbole DOT bologna DOT it