S
Stephen Sprunk
Would it be too much trouble to ask to see the exact source
you actually compiled and run? The source as posted has at least
two problems: The twodouble/twdouble mismatch,
Change made in source and recompiled/executed:
% cat foo.c
#include <stdio.h>
#define alignof(t) __alignof__(t)
struct twodouble { double x; double y; };
int main(void) {
printf("alignof(double) = %zu\n", alignof(double));
printf("alignof(double[2]) = %zu\n", alignof(double[2]));
printf("alignof(double complex) = %zu\n", alignof(double _Complex));
printf("alignof(struct twodouble) = %zu\n", alignof(struct twodouble));
}
% gcc -std=c99 -pedantic -W -Wall foo.c
% ./a.out
alignof(double) = 8
alignof(double[2]) = 8
alignof(double complex) = 8
alignof(struct twodouble) = 4
and the use of __alignof__ (compiler-specific magic? another typo? or
what?).
My GCC doesn't support _Alignof(), but __alignof__ should be the same.
It's possible that, for a related reason, GCC doesn't provide the
expected alignment for struct twodouble. Unfortunately, I can't upgrade
it right now to see if the result has changed in more recent versions.
S