packed is a variable attribute that is used with structures and unions in order to minimize the memory requirements.
#include <stdio.h>
struct foo {
int a;
char c;
};
struct __attribute__((__packed__))foo_packed {
int a;
char c;
};
int main()
{
printf("Size of foo: %d\n", sizeof(struct foo));
printf("Size of packed foo: %d\n", sizeof(struct foo_packed));
return 0;
}
On my 64 bit Linux,
packed attribute curbs the structure padding that the compiler performs to maintain memory alignment.