Path: utzoo!utgpu!news-server.csri.toronto.edu!rutgers!cs.utexas.edu!rice!uupsi!grebyn!ckp From: ckp@grebyn.com (Checkpoint Technologies) Newsgroups: comp.lang.c Subject: Re: Forward referrence of static variables. Message-ID: <24413@grebyn.com> Date: 2 Jan 91 17:12:12 GMT References: <1991Jan2.084213.19442@cai.uucp> Reply-To: ckp@grebyn.UUCP (Checkpoint Technologies) Distribution: usa Organization: Grebyn Timesharing, Vienna, VA, USA Lines: 34 In article <1991Jan2.084213.19442@cai.uucp> davel@cai.UUCP (David W. Lauderback) writes: >I think there is no "clean" solution to the problem I have but I wanted to test >my ability to post on the net so here is the problem: In fact, I may have an appropriate solution. >I have some structures that make up a doublely linked list that I wish to >initialize. The problem is I can't have two structures linked to each other. > [example deleted] Try this: struct some_thing { struct some_thing *next, *prev; /* ... other members */ }; struct some_thing things[] = { { &things[1], NULL, }, { &things[2], &things[0], }, { &things[3], &things[1], }, ...and so on. You get the idea. This won't work if you have different structure types to resolve this way; or else you could make a union of them, though only ANSI specifies union initialization I understand. You could make #defines for the individual array members if you want to avoid referring to them as things[n]. -- First comes the logo: C H E C K P O I N T T E C H N O L O G I E S / / \\ / / Then, the disclaimer: All expressed opinions are, indeed, opinions. \ / o Now for the witty part: I'm pink, therefore, I'm spam! \/