how about sizeof(((type *)1)->member) ?

Dave Decot decot at hpisod2.HP.COM
Sun Oct 29 05:54:05 AEST 1989


> In article <1989Oct27.141015.20578 at talos.uucp> kjones at talos.uu.net writes:
> >If sizeof(((type *)0)->member) is forbidden, then is
> >sizeof(((type *)1)->member) forbidden as well, in pANS
> >conforming programs?
> 
> The latter is not guaranteed to work in all implementations,
> due to variation in addressing architectures (and memory "models").
> For example, "type" objects may require quadword alignment,
> and the compiler can easily tell that the address constant value 1
> does not satisfy that constraint.

OK, fine.  My what a tiresome language.  Here:

    sizeof(((struct foo *)(sizeof(struct foo)))->member)

Dave



More information about the Comp.lang.c mailing list