erik quanstrom wrote:
The point is how to compute the offset(s) of the last field at compile /
run time.
the offset of the last field is not in question. i believe you mean the size?
It's really the same info.
struct
{
..... // total sizeof = 100
int B[..];
}A;
offset(B) = 100, &(A.B[7]) == address(A) + 100 + 7*sizeof(int).
The compiler accept the dirty but legal expression A.B[-3] because it
can compute
the address (or the offset with respect the beginnig of "A") of the B
"-3" cell.
But in this case
struct
{
..... // total sizeof = 100
struct B B;
}A;
with B declared (just named), how 8c could determined the address of A.B.x ?
To accept the above definition of A, say in a global .h, means that every .c
should include the definition of B.
They could be - legally - different, so generating different offsets of
"x" with respect A
in the same program.
I prefer to have only the tricky but standard "char x[0]" tails.
i'd prefer not to have them, either. but it's too late for that.
:-) And what about
char x[...] and x[2] == 2[x] :-) :-)
Your patch will be included in the next distribution CD ?
no. i haven't submitted it yet.
- erik
adriano