Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!brutus.cs.uiuc.edu!wuarchive!wugate!uunet!ibmpa!lmb From: lmb@ibmpa.UUCP (Larry Breed) Newsgroups: comp.lang.c Subject: Re: Struct definition in MS-C Keywords: pointer, linked list, Microsoft C Message-ID: <1828@ibmpa.UUCP> Date: 23 Aug 89 22:03:19 GMT References: <10761@smoke.BRL.MIL> <1989Aug18.101819.3634@twwells.com> Reply-To: lmb@ibmpa.UUCP (Larry Breed) Organization: IBM AWD, Palo Alto Lines: 32 In article <1989Aug18.101819.3634@twwells.com> bill@twwells.com (T. William Wells) writes: > >struct node { > ... >}; >foo() >{ > struct node { > struct node *next; > }; > >The "struct node *" is, I think, going to refer to the global struct >node, not the local one; in that case, adding an additional "struct >node;" at the start of the function will fix things. The struct node defined in foo has scope starting at the left brace of its declaration. (pANS 3.1.2.1 paragraph 5.) This was true in K&R C as well. Therefore the "struct node *" refers to the local struct node. This odd rule for where scope begins is the reason for the curious statement (3.1.2.1 para 4): "Two identifiers have the same scope if and only if the scopes terminate at the same point." It has to be described this way because every identifier's scope starts at a different point. -- Larry Breed inet: lmb%ibmsupt@uunet.uu.net uucp: uunet!ibmsupt!lmb (415) 855-4460