delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/03/12/11:31:26

From: G DOT DegliEsposti AT ads DOT it
To: djgpp AT delorie DOT com
Message-ID: <C12565C5.00576C6E.00@vega.ads.it>
Date: Thu, 12 Mar 1998 16:59:56 +0100
Subject: Re: PACKED situation
Mime-Version: 1.0




>Hi all,
>    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:

---

Alternatively, you could declare any single structure to be packed, like
so:

       struct {
         char name[7];
         unsigned long offset;
         double quality;
       } __attribute__ ((packed));

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.

---

ciao
  Giacomo


- Raw text -


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