分类: LINUX
2009-07-14 23:30:38
#include <stdio.h>
{
char a;
int b;
char c;
int d;
};
#pragma pack (2)
struct Foo2
{
char a;
int b;
char c;
int d;
};
#pragma pack ()
struct Foo3
{
char a;
char c;
int b;
int d;
};

struct Foo4
{
char a;
int b;
char c;
int d;
} __attribute__ ((__packed__));

int main(int argc, char **argv)
{
printf("size of Foo1: %d ", sizeof(struct Foo1));
printf("size of Foo2: %d ", sizeof(struct Foo2));
printf("size of Foo3: %d ", sizeof(struct Foo3));
printf("size of Foo4: %d ", sizeof(struct Foo4));

return 0;
}
~