how about sizeof(((type *)1)->member) ?
Doug Gwyn
gwyn at smoke.BRL.MIL
Tue Oct 31 00:37:07 AEST 1989
In article <2550111 at hpisod2.HP.COM> decot at hpisod2.HP.COM (Dave Decot) writes:
>OK, fine. My what a tiresome language. Here:
> sizeof(((struct foo *)(sizeof(struct foo)))->member)
The constraint is not imposed by the language, but rather by the
available computer architectures. Since C permits the programmer
to get "close" to the architecture, these warts become more
visible than in some higher-level languages.
The reason offsetof() is specified as part of a conforming
implementation in the C Standard is to keep programmers from
trying to concoct their own non-portable invention for this.
More information about the Comp.lang.c
mailing list