2 #include <stddef.h> /* offsetof() */
8 struct s0 {char c0; double d0;};
9 struct s1 {double d1; int i1; char c1;};
10 struct s2 {double d2; int i2; char c2[6];};
11 struct s3 {double d3; int a3; int b3;};
13 int gras_struct_packed;
14 int gras_struct_compact;
15 int gras_array_straddle_struct;
16 int gras_compact_struct;
18 if (sizeof(struct s0) == sizeof(double)+sizeof(char))
26 if (offsetof(struct s1,c1) == sizeof(double)+sizeof(int))
28 gras_struct_compact=1;
32 gras_struct_compact=0;
34 if (offsetof(struct s2,c2) == sizeof(double)+sizeof(int))
36 gras_array_straddle_struct=1;
40 gras_array_straddle_struct=0;
42 if (offsetof(struct s3,b3) == sizeof(double)+sizeof(int))
44 gras_compact_struct=1;
48 gras_compact_struct=0;
52 if(gras_struct_packed == 0 && gras_struct_compact == 1) printf("GRAS_STRUCT_COMPACT ");
54 if(gras_array_straddle_struct == 1) printf("GRAS_ARRAY_STRADDLE_STRUCT ");
56 if(gras_compact_struct == 1) printf("GRAS_COMPACT_STRUCT ");