Path: utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!usc!cs.utexas.edu!uunet!mcvax!ukc!kl-cs!pc From: pc@cs.keele.ac.uk (Phil Cornes) Newsgroups: comp.lang.c Subject: Re: Help, page 197 K&R !!! Message-ID: <648@kl-cs.UUCP> Date: 30 Jun 89 13:46:06 GMT References: <646@kl-cs.UUCP> Organization: University of Keele, England Lines: 34 From article <646@kl-cs.UUCP>, by atula@cs.keele.ac.uk (Atula Herath): > Could somebody please explain me follwing para, from the K&R. > > Page 197, para 7 : > > What does that mean ? > This is a paragraph in the 1st edition K&R. The paragraph details a restriction on the choice of member names in structures and unions. The restriction itself is fairly easy to understand, though most C compilers now available don't enforce it so it is not as easy to demonstrate. K&R C says that member names in structures and unions must (in general) be unique. This is because in early implementations the names of structure and union members were not associated with their parent names, but were only stored as a type and offset from the start of the parent. Attempting to use the same member name in two places would therefore usually involve trying to assign two different type and offset values to that name (clearly not allowed). Page 197 para 7 however, goes on to say that if using the name in two places would lead to the same type and offset values being allocated for both then this is okay. Most current K&R compilers and ANSI compilers don't have this problem because they associate parent names with member names, thus automatically making unique names out of each member name so that the same member name may appear in more than one place (though obviously not twice within the same struct or union). --- Phil Cornes -----------* cdtpc@uk.ac.stafpol.cr83 ---