??: PR 1098: "struct ipovly" not packed.

Ralf Corsepius ralf.corsepius at rtems.org
Wed Jul 12 01:18:58 UTC 2006

On Tue, 2006-07-11 at 12:52 -0500, Jay Monkman wrote:
> Ralf Corsepius wrote:
> > 
> > structs like the ones above are BAD DESIGN.
> > 
> > With or without __attribute((packed))__ there is no guarantee they will
> > work. If you have a look into the BSD structures we are talking about
> That's not what the gcc docs say:
GCC != C

>      The `packed' attribute specifies that a variable or structure field
>      should have the smallest possible alignment--one byte for a
>      variable, and one bit for a field, unless you specify a larger
>      value with the `aligned' attribute.
> If __attribute__((packed)) is so wrong,
It isn't "so wrong", it's "hack", "band-aid", "means of last-resort" or
whatever you want to call it.

>  what's the correct way to ensure a data
> structure is packed?
Not relying on packing.

struct { int; short; int;} requires packing,
struct { int; int; short;} shouldn't.

The test case I sent last week had proven that arm-gcc packs them
correctly => "packing" is not the explanation for the symptoms.

The still open question is "What is going wrong and where?"

>  If you look at the latest code in netbsd,
NetBSD != FreeBSD.

>  they use it on
> their network data structures:
> http://cvsweb.netbsd.org/bsdweb.cgi/~checkout~/src/sys/netinet/tcp.h?rev=
The fact others use it, doesn't mean much.


More information about the users mailing list