This is the mail archive of the
ecos-discuss@sourceware.org
mailing list for the eCos project.
Re: pragma pack
Beware of bad alignment of timestamp field. Some processors might
raise an exception/interrupt when you use the int like operation
directly on field (including assignment & evaluation). You should copy
out/in this by memcpy into/from temporary variable of the same type
when you need to do some integer computing on this field. In other
case your code might not be portable.
Best Regards
Bronislav Gabrhelik
2008/1/9, Alexandre <thekyz@gmail.com>:
> Thanks a lot to all of you,
>
> I'm gonna try what you wrote to see if it works Olaf, but what Andrew
> told me resolved the problem. My structure is now defined like this:
>
> typedef struct __attribute__ ((__packed__)) s_pelco_pattern_array{
> cyg_uint8 command2_byte;
> cyg_uint8 data3;
> cyg_uint8 data4;
> cyg_uint16 timestamp;
> } pelco_pattern_array;
>
> and is actually 5 bytes large :)
>
> I was reffering to this page of the gcc doc for the "pack" pragma and
> thought it would work, maybe what Bernard pointed should also help
> resolve the problem about the pragma:
>
> http://gcc.gnu.org/onlinedocs/gcc/Structure_002dPacking-Pragmas.html
>
> Again, thanks a lot, i'm still gonna push a little my research on this
> matter and i'll get you all updated.
>
> Alex Garcia
> Hymatom SA
>
> PS: Sorry for the double mail Bernard :(
>
> --
> 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