Mail Archives: djgpp/1997/10/14/14:00:41
On Tue, 14 Oct 1997, Herman Geza wrote:
> Hi there!
>
> I have a little problem with GNU C++. When I make a struct type,
> and I add __attribute__((packed)), it doesn't work. The compiler
> behaves as if the __attribute__((packed)) wasn't there...
> If I compile my program with simple C, it works.
I suspect the reason for this may be the one given in Sec 22.9 of the
DJGPP FAQ. In the absence of a code snippet, I can only guess and I hope I
am right! One possible reason is that the syntax for declaring
__attribute__ ((packed)) differs slightly between C and C++. In C++, you
need to declare the attribute after *every* member of the struct. For
example:
struct tag{
type1 member1 __attribute__ ((packed));
type2 member2 __attribute__ ((packed));
...
typen membern __attribute__ ((packed));
} instance;
In C this may be written only once at the end.
I hope this helps!
- Raw text -