You can use AC_COMPUTE_INT
:
AC_COMPUTE_INT([payload_offset], [offsetof(struct bar, payload)], ...)
But it would probably be easier just to use an anonymous union to force alignment:
struct foo {
struct {
int a;
int b;
long len;
unsigned short c;
unsigned short d;
};
union {
char payload[1024];
double dummy; /* for alignment */
};
} bar;
If you don't want to use a union, you can compute the padding in place:
struct foo {
struct header {
int a;
int b;
long len;
unsigned short c;
unsigned short d;
};
char padding[(alignof(double) - 1) - ((sizeof(struct header)
+ alignof(double) - 1) % alignof(double))];
char payload[1024];
} bar;