Path: utzoo!utgpu!water!watmath!clyde!rutgers!husc6!hao!oddjob!gargoyle!ihnp4!cbosgd!osu-cis!tut!lvc From: lvc@tut.cis.ohio-state.edu (Lawrence V. Cipriani) Newsgroups: comp.lang.c Subject: Re: struct a <---> struct b Message-ID: <6573@tut.cis.ohio-state.edu> Date: 14 Feb 88 18:52:55 GMT References: <11774@brl-adm.ARPA> Organization: The Ohio State University Dept of Computer and Information Science Lines: 45 In article <11774@brl-adm.ARPA> Alan_T._Cote.OsbuSouth@Xerox.COM writes: >Finally -- one I can answer!! > >>What is the best way to declare three different structures, each containing a pointer >>to the other two? I keep running into a forward referencing error. > >Try declaring all three as externals ahead of time. Try the following: The way I took this question was that the different structures are also of different type. If this is the case the answer is different. Do the following: struct a; /* Hey compiler! a b and c are structures */ struct b; /* that I will define later */ struct c; struct a { struct b *pb; struct c *pc; ... /* other stuff */ }; struct b { struct a *pa; struct c *pc; ... /* other stuff */ }; struct c { struct b *pb; struct c *pc; ... /* other stuff */ }; The initialization of the pointers is left as an exercise for the interested reader. -- oo Larry Cipriani, AT&T Networks Systems (by day) Ohio State University (by night) Domain: lvc@tut.cis.ohio-state.edu Path: ...!cbosgd!osu-cis!tut.cis.ohio-state.edu!lvc (yes its right)