On Fri, 2005-04-15 at 09:27 -0600, E. Weddington wrote:
> Ralf Corsepius wrote:
> 
> >Hi,
> >
> >I just tripped over this snipped below in a piece of code, I didn't
> >write and which I don't understand:
> >
> >...
> >struct somestruct {
> >  struct entrystruct *e1 __attribute__ ((packed));
> >  struct entrystruct *e2 __attribute__ ((packed));
> >};
> >...
> >
> >Is this meaningful?
> >
> >I guess the author wanted e1 and e2 to point to a 
> >"packed struct entrystruct", but this doesn't seem to be what GCC
> >interprets this code.
> >
> >
> >  
> >
> 
> Take a look at the manual in the section about attributes of variables,
> <http://gcc.gnu.org/onlinedocs/gcc-3.4.3/gcc/Variable-Attributes.html#Variable-Attributes>

I read this, over and over again, before posting, but ...

> It seems that GCC will interpret the above as e1 and e2 is packed within 
> the struct somestruct so that e2 "immediately follows e1" (according to 
> the manual). The packed attribute in this case does not refer to what e1 
> and e2 is pointing to.
That's what I found out by experimenting and is the reason why I am
asking. From what I see on i386,

struct entrystruct * entry __attribute__ ((packed));

is interpreted as "packed pointer to struct"
not as "pointer to packed struct",
i.e. this construct is not meaningful.

>  Though I'm not sure what putting the packed 
> attribute on e1 will buy you.
You've got the point - I am collecting ammunition to fight a stubborn
original author :-)

Ralf



Reply via email to