std C/C++ and packed
Douglas S. J. De Couto
decouto at lcs.mit.edu
Fri Apr 26 18:13:21 EDT 2002
based on my experience with userlevel click on a strongarm, packed is
required on some of the wire format fields so that the sizeofs work.
e.g. with arm-linux-g++, sizeof(ether_hdr) != 14 unless the pack
attribute is applied. (cf. CVS v1.2 of click_ether.h)
now, i probably shouldn't be using the sizeof notation in my code for
determining sizes of wire format packets, but that's another question...
David Scott Page wrote:
> Hi,
>
> This is the last error message to conquer (although there are a few
> warnings that I'd like to look into when I get a chance).
>
> In click/include/click/click_ether.h, fddi.h, and rfc1483.h, the
> __GNUC__ __attribute__ ((packed)) is appled to structures describing
> wire syntax. While one field of the fddi.h structures needs packing,
> it seems packed is gratuitously used on the others. Regarding the
> structure as a whole (e.g., access via a reinterpret_cast):
....
> Suggestions?
half tongue in cheek, half serious: convert all code that directly
overlays structs onto packet data to explicitly fill-in/extract fields
to/from the packet data, avoiding issues with the sizeof (and alignment
issues).
d
--
Douglas S. J. De Couto decouto at lcs.mit.edu
More information about the click
mailing list