__attribute__((packed, aligned(4)))?

Hi,

Does anyone have a good model for how the "packed" and "aligned"
attributes interact?

For example:

struct Foo __attribute__((packed, aligned(4))) {
    int a;
    char b;
    int c;
};

struct Foo var;

It seems that alignof(var) == 4, but alignof(var.a) == 1. This is
surprising to me.

Is this just a GCC quirk that we've had to emulate or is there a good
reason for it?

Cheers.

Tim.

This is what gcc does. It's not worth trying to deviate from gcc here.

-Eli