This is the mail archive of the
ecos-discuss@sourceware.org
mailing list for the eCos project.
Re: Re: pragma pack
- From: Alexandre <thekyz at gmail dot com>
- To: "Paul D. DeRocco" <pderocco at ix dot netcom dot com>
- Cc: ecos-discuss at ecos dot sourceware dot org
- Date: Thu, 10 Jan 2008 10:42:40 +0100
- Subject: Re: [ECOS] Re: pragma pack
- References: <fm3mgi$v4$1@ger.gmane.org> <015801c85322$bf2055e0$887ba8c0@PAULD>
- Reply-to: thekyz at gmail dot com
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