std C/C++ patch #9
David Scott Page
page at cs.utexas.edu
Fri May 3 11:28:43 EDT 2002
Eddie,
> I've updated the repository to use two new macros,
> CLICK_SIZE_PACKED_STRUCTURE (for the arm-gcc case: to convince the compiler
> that a structure needs to be smaller than it might like) and
> CLICK_PACKED_STRUCTURE (for the FDDI/BridgeMessage case: where holes INSIDE
> the structure are not allowed). Defined in config.h[.in].
>
> CLICK_PACKED_STRUCTURE will cause an error when used w/o GCC. I expect the
> user to redefine it appropriately -- probably by #defining it to /*empty*/
> and hoping for the best.
>
> Also, I added a bunch of static_asserts to ensure that all the address
> structures really have the right size.
Looks good and simplifies compiling with non-GCC compilers (and I like
the clever static_assert). For KCC, the static assert on
click_fddi_snap fails no matter what; since the sizeof is tested by
the KCC frontend, while a #pragma pack does not take hold until the
generated C code is compiled. This is okay in my world, since no one
in their right mind is going to compile click with -misalign and
double its run-time. My workaround is to just comment out the
static_assert for that structure, and use ethernet.
By the way, what does two arguments to the PACKED_STRUCTURE macro buy
you?
--
Scott Page
More information about the click
mailing list