Path: utzoo!utgpu!news-server.csri.toronto.edu!rutgers!cs.utexas.edu!uunet!cai!davel From: davel@cai.uucp (David W. Lauderback) Newsgroups: comp.lang.c Subject: Forward referrence of static variables. Message-ID: <1991Jan2.084213.19442@cai.uucp> Date: 2 Jan 91 08:42:13 GMT Reply-To: davel@cai.UUCP (David W. Lauderback) Distribution: usa Organization: Century Analysis Incorporated Lines: 44 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: 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: -------------------- struct ll { struct ll *prev; /* link to previous element */ struct ll *next; /* link to next element */ /* more fields ... */ }; /* Location 1 */ static struct ll first = { 0, &last /* , more data */ }; static struct ll last = { &first, 0 /* , more data */ }; -------------------- My solution is to add "extern struct ll last;" at location 1 and remove the static's. But I would much prefer to leave them static. So back to the original question, is there a way to forward referrence static variables? I can think of two other unacceptable solutions. One is to initialize these in the code segment but this is harder to support and uses valuable space in my particular application. Another is that compilers will let you extern a variable and then make it static, with a warning message. However, this is not portable so I can't use it. Thank in advance, David W. Lauderback uunet!cai!davel PS. Please respond even if you don't have a comment. I am trying to see how far this message gets. I used distribution usa. Should I have used a narrower distribution for this type of question? Like ca maybe? -- ----------------------------------------------------------------------------- | ### # ### | David W. Lauderback (a.k.a. uunet!cai!davel)| | # # # # # | | | # # # # | (this space temporarily left blank) |