I have two structs like
struct X {
int x;
double *y;
};
struct Y {
int a;
double *b;
char c;
};
Is casting a pointer to struct Y
to a pointer to struct X
guaranteed to behave consistently in a reasonable manner (i.e. x->x
and x->y
correspond to y->a
and y->b
respectively) by the C89 standard? Less important, but would be really cool if you also happen to know, does this hold true for later standards as well (e.g. C11) and other languages that have significant syntactic and semantic overlap with C (e.g. C++XX, Objective-C)?