accessing initial common structure members

Henry Spencer henry at zoo.toronto.edu
Sun Oct 21 15:10:28 AEST 1990


In article <31468 at netnews.upenn.edu> kozak at grad1.cis.upenn.edu (Chuck Kozak) writes:
>I have seen code where the first N members of different structures
>are accessed by code that treats the structures as identical.  I
>looked through K&R II to check whether this practice is legal and
>cannot find any mention of it...

ANSI C promises that this will work only when all the structures in
question are within a union.  (Sufficiently determined theological
reasoning might possibly demonstrate that this suffices to guarantee
it everywhere.)  It is dubious practice at best.
-- 
The type syntax for C is essentially   | Henry Spencer at U of Toronto Zoology
unparsable.             --Rob Pike     |  henry at zoo.toronto.edu   utzoo!henry



More information about the Comp.lang.c mailing list