This is the mail archive of the crossgcc@sources.redhat.com mailing list for the crossgcc project.

See the CrossGCC FAQ for lots more information.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Structure alignment problem


On Mon, Nov 04, 2002 at 12:41:10PM +0000, Richard Earnshaw wrote:

> > > Because you need to pack the structure as a whole, not just the members of 
> > > it.
> >  
> > > Try
> > > 
> > > typedef struct {
> > >     unsigned char Var1;
> > > } mystruct __attribute__((packed));
> > > 
> > > R.
> > 
> > Tried that does not work !!
> 
> Ah, yes; that's because of a long-standing bug in gcc.  Separate the 
> typedef from the structure declartion and it should all be fine.  Ie
> 
> struct mystruct {
>     unsigned char Var1;
> }  __attribute__((packed));
> 
> typedef struct mystruct mystruct;
> 
> Life is such fun...

Ah, Ha!  I've got to carve that one into my cube wall...

I beat my head against that one for a couple days and never
figured it out.  I asked on the gcc mailing list and all I got
were adminishments for trying to use structs to layout data in
an externally defined manner.

-- 
Grant Edwards
grante@visi.com

------
Want more information?  See the CrossGCC FAQ, http://www.objsw.com/CrossGCC/
Want to unsubscribe? Send a note to crossgcc-unsubscribe@sources.redhat.com


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]