delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/03/12/13:38:15

Message-Id: <199803121839.UAA54786@ieva06.lanet.lv>
From: "Andris Pavenis" <pavenis AT laima DOT acad DOT latnet DOT lv>
To: djgpp AT delorie DOT com, G DOT DegliEsposti AT ads DOT it
Date: Thu, 12 Mar 1998 20:36:49 +0000
MIME-Version: 1.0
Subject: Re: PACKED situation
In-reply-to: <C12565C5.00576C6E.00@vega.ads.it>

> From:          G DOT DegliEsposti AT ads DOT it
> Subject:       Re: PACKED situation

> >    standard problem with PACKED taken from faq.
> >It's a bug in a version of djgpp which according to the faq s been fixed
> >in the djdev201.zip version.  The faq says that the structure gets
> >messed up.  I get the error below where the ";" is stated as missing.
> >I've been running djdev201.zip derived files for about a year.  So
> >version should not be my problem.
> >
> >typedef struct {
> >  DWORD style;
> [...]
> >  WORD  id;
> >} PACKED DLGITEMTEMPLATE;  //Error ; missing after struct declaration.
> It seems like you can't do like this if using C++ but only with C!
> Quoting faq 22.9:
> 

 
> However, note that the latter will only work when you compile it as a C
> source; C++ doesn't allow such syntax, and you will have to fall back to
> declaring each struct field with the packed attribute.  Therefore, it's
> best
> to only use declarations such as above if you are *certain* it won't be
> ever
> compiled as a C++ source.
> 


The following works perfectly with C++ source (You'll get packed 
structure)

 #  pragma pack(1)

        struct {
          char name[7];
          unsigned long offset;
          double quality;
        };

 #  pragma pack()



Andris Pavenis 

- Raw text -


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