1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
#include <stdio.h>
static struct sss{
long f;
short a[10];
} sss;
#define _offsetof(st,f) ((char *)&((st *) 16)->f - (char *) 16)
int main (void) {
printf ("++++Array of short in struct starting with long:\n");
printf ("size=%d,align=%d\n",
sizeof (sss), __alignof__ (sss));
printf ("offset-long=%d,offset-arrayof-short=%d,\nalign-long=%d,align-arrayof-short=%d\n",
_offsetof (struct sss, f), _offsetof (struct sss, a),
__alignof__ (sss.f), __alignof__ (sss.a));
printf ("offset-short-a[5]=%d,align-short-a[5]=%d\n",
_offsetof (struct sss, a[5]),
__alignof__ (sss.a[5]));
return 0;
}
|