[ECOS] Re: pragma pack

Alexandre thekyz@gmail.com
Thu Jan 10 09:43:00 GMT 2008


Actually i had some problems accessing my packed structures without
flows, I think that may help resolve things a bit.
Eg with things like that:

cyg_uint8 i = 0;
struct s_pelco_pattern_array a;

a.command2_byte = i++;
a.data3 = i++;
a.data4 = i++;
a.timestamp = i;

I finish having a structure which looks like this in memory:

cm2: 0x00
data3: 0x01
data4: 0x02
ts: 0x0300

Which is really not what i want to have eventually.

On Jan 10, 2008 1:50 AM, Paul D. DeRocco <pderocco@ix.netcom.com> wrote:
> > From: Grant Edwards
> >
> > The trap snaps shut when you take the address of a field in a
> > packed struct and pass that to somebody who's expecting a
> > pointer to a normally aligned value.
>
> True. I could imagine ways in which the type system could be designed to
> prevent that, using a pointer modifier like "int __packed*", but it's not.
>
> Anyway, for normal accesses, it works fine, so you can do things like
> operate on the fields in a DOS boot sector without problems. That's the only
> situation I've ever needed the feature.
>
> --
>
> Ciao,               Paul D. DeRocco
> Paul                mailto:pderocco@ix.netcom.com
>
>
> --
>
> Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
> and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss
>
>

-- 
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss



More information about the Ecos-discuss mailing list