sizeof a struc field
Doug Gwyn
gwyn at smoke.BRL.MIL
Thu Oct 19 20:07:51 AEST 1989
In article <1234 at crdos1.crd.ge.COM> davidsen at crdos1.UUCP (bill davidsen) writes:
>What the original poster wanted was the size of a field within a struct.
>He proposed using:
> sizeof(((struct mytype *)0)->field)
>which involves using a null values pointer. The value of this under pcc
>compilers is the size of the field within a struct mytype. You interpret
>the standard to forbid this.
No, what I say is that the Standard does not require that it work
as the programmer seems to expect it to. That's not the same thing.
A conforming implementation is free to make it work if it so chooses.
It is also free to not make it work.
>Do you also interpret the standard to forbid:
> int fieldlen = sizeof(head->a);
Of course not. It does forbid
int fieldlen = sizeof(((struct mytype*)0)->a).
As I keep telling you, it is NOT an issue about sizeof!
It's an issue about ->.
So long as you persist in trying to determine this by reading the
sizeof specs in the Standard, you'll never understand what I'm saying.
More information about the Comp.lang.c
mailing list