This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


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

Re: How to stop gcc padding structs???



> > > Relying on sizeof to do this is *very* non-portable.
> > 
> > It's a device driver for a specific board.  It doesn't really
> > need to be portable.
> > 
> > > Try:
> > > 
> > > typedef struct
> > > {
> > >   volatile unsigned char data;
> > >   volatile unsigned char _xxx;
> > > } __attribute((packed)) high;
> > 
> > Several people suggested that, but it didn't make any
> > difference:
>
> Hmm, it looks to me like you are using a very old compiler (I fixed this 
> donkeys ages ago -- probably before egcs tree forked).

$ arm-elf-gcc -v       
Reading specs from /usr/local/lib/gcc-lib/arm-elf/2.95.2/specs
gcc version 2.95.2 19991024 (release)

I'm running big-endian...

> BTW splitting the struct declaration from the typedef should still work, 
> even on the old compiler.  hence
> 
> struct foo {
>   char a;
>   char b;
> } __attribute((packed));
> 
> typedef struct foo bar;

Thanks, I'll give that a shot.

-- 
Grant Edwards
grante@visi.com

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