Yahoo Groups archive

Lpc2000

Index last updated: 2026-04-28 23:31 UTC

Message

Re: Confused re: endianness

2005-10-19 by rtstofer

--- In lpc2000@yahoogroups.com, "rtstofer" <rstofer@p...> wrote:
>
> --- In lpc2000@yahoogroups.com, Richard Duits <yahoo@r...> wrote:
> >
> > If you use an "__attribute__((packed))" structure with GCC, the 
> compiler 
> > assumes it is not aligned and reads everything one byte at a 
time 
> (even 
> > if it is aligned).
> > 
> > Richard Duits.
> 
> Thanks!  I'll give it a try right now.
> Richard
>

Initially I had no success but on reflection I realized the example 
was too large to test.

I created a small structure

struct frame {
 unsigned char b;
 unsigned short w; // misaligned
 unsigned int d; // misaligned
} __attribute__ ((packed));

and worked with that.  The __attribute__ does solve my problem.  Now 
I need to rework the structures...

Thanks!
Richard

Attachments

Move to quarantaine

This moves the raw source file on disk only. The archive index is not changed automatically, so you still need to run a manual refresh afterward.