zero length array

Michael Meissner meissner at dg_rtp.UUCP
Sat Mar 7 04:46:24 AEST 1987


In article <1987Feb25.201816.29714 at gpu.utcs.toronto.edu> woods at gpu.utcs.UUCP (Greg Woods) writes:
> In article <4498 at brl-adm.ARPA> Dizio at udel.edu writes:
> >   Is the following a portable way of finding out where a field
> >within a structure is located?
> >
> >    & (((struct any_struct_tag *) 0)->any_field)
> 
> Not that I know of, though the expression without "&" is usefull in sizeof().
> 
> Some compilers will refuse to cast NULL, specifically Lattice C up to 2.15(?)
> As far as I know all Unix compilers will cast NULL.
> 
> You might want to cast one(1) instead.  Lattice will accept this.
> 
> 						Greg Woods.

I believe the harris compiler also has problems with this.  Also any
implementation which does not produce all zero bits for integer 0 -> pointer
(or vica versa) would have problems with this.  That's why offsetof was
created in ANSI.
-- 
	Michael Meissner, Data General	Uucp: ...mcnc!rti-sel!dg_rtp!meissner

It is 11pm, do you know what your sendmail and uucico are doing?



More information about the Comp.lang.c mailing list