delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2000/05/04/12:58:26

Date: Thu, 4 May 2000 18:30:04 +0200 (WET)
From: Andris Pavenis <pavenis AT lanet DOT lv>
To: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
cc: Alexandre Devaure <Alexandre DOT Devaure AT leroy-autom DOT com>, djgpp AT delorie DOT com
Subject: Re: structures size
In-Reply-To: <Pine.SUN.3.91.1000504171145.19305A-100000@is>
Message-ID: <Pine.A41.4.05.10005041827250.48816-100000@ieva05.lanet.lv>
MIME-Version: 1.0
Reply-To: djgpp AT delorie DOT com
Errors-To: nobody AT delorie DOT com
X-Mailing-List: djgpp AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com


On Thu, 4 May 2000, Eli Zaretskii wrote:

> 
> On Thu, 4 May 2000, Alexandre Devaure wrote:
> 
> > > What did you expect this program to print?
> > 
> > I forgot to include the definition of the types used in the structures :
> > typedef unsigned short uint;
> > typedef unsigned char uchar;
> > typedef unsigned int ulong;
> > 
> > And I want the size to be 15 bytes.
> 
> It works for me, but not with GCC 2.95.x, which has a bug when you use 
> the -fpack-struct switch, as explained in the FAQ.  If you have that 
> version of GCC, you will have to use __attribute__((packed)) instead.
> See section 22.11 of the DJGPP FAQ for more details.
> 

It's also possible to use 

#pragma pack(1)

struct foo 
  {
     .....
  };

#pragma pack()

It works with gcc-2.95.2 (at least in my code written in C++)

Andris

- Raw text -


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