Kristof Bastiaensen said:
static recurs a = {5, &b};
static recurs b = {4, &a};
Others have hinted at re-doing your design to avoid this sort
of thing. Let me make a hint about direction of redesign.
These two things are probably suggestive of some larger issue
in your code. I doubt you'd bother with this just to store the
numbers 4 and 5. So you seem to have reduced your actual issue
from "how do I do this larger problem?" to "I've got a way to
do it that involves this smaller problem, how do I do this smaller
problem?"
Step back from struggling with the small issue and ask, why does
the thing "a" need to know about the thing "b"? And why does
the thing "b" *ALSO* need to know about the thing "a"?
What functionality is associated with that link?
What is their actual relationship? Is there a linked list
of some kind lurking here? If so, then what you really want
to do is build a linked list and shove the data in there.
Are these things really in some kind of heirarchy? Then
maybe you want to organise things based on a tree of some
kind. Or maybe, it's just a way of keeping them together
in a particular order, in which case you really want them
in a vector.
In other words, maybe you are trying to shoe-horn
a relationship that is easy in run-time initialization into
one that is quite hard in compile-time initialization.
In other words, it looks like you've settled on one way of
doing things. You seem to want to do it that way
and if you could only get a little help from the stubborn old
gurus here, you'd be able to finish your code in record time.
But what they are telling you is, there are almost certainly
easier ways to do this than by trying to seduce the compiler.
Hey, it may mean that your code takes a 1/4 second longer to
load and start doing actual work. Compare that to struggling
with your app for several days. Or possibly finding this scheme
busts when you add some new level of complexity, and spending
several weeks ripping out the old code and doing it the way
the gurus suggested anyway.
Or, to put it another way, what you think is a smaller problem
on your way to the larger issue may not be so small after all.
What turns out to be easy, and what turns out to be a smegger of
a pain in the ass, is something you should really listen to the
gurus about. Many of them got to be gurus by barking their shins,
often repeatedly, over just the same kind of issue. Others were
amazingly lucky and listened to the previous guys down the trail,
and didn't trip over the same logs.
Socks