Forward referrence of static variables.
Checkpoint Technologies
ckp at grebyn.com
Thu Jan 3 04:12:12 AEST 1991
In article <1991Jan2.084213.19442 at cai.uucp> davel at 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! \/
More information about the Comp.lang.c
mailing list