1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
| struct example1 {
char c1;
short s;
char c2;
int l;
};
struct example2 {
char c1;
short s;
char c2;
int l;
}__attribute__ ((aligned (1)));
struct example3 {
char c1 __attribute__ ((aligned (4)));
short s __attribute__ ((aligned (4)));
char c2 __attribute__ ((aligned (4)));
int l;
};
struct example4 {
char c1;
short s;
char c2;
int l;
}__attribute__ ((__packed__));
int main(){
printf("char : %d, short : %d, long : %d\n", sizeof(char), sizeof(short), sizeof(int));
printf("1 : %d, 2 : %d, 3 : %d, 4 : %d\n", sizeof(struct example1), sizeof(struct example2), sizeof(struct example3), sizeof(struct example4));
} |
Partager