Initialization
Dan Bernstein
brnstnd at kramden.acf.nyu.edu
Fri Oct 5 07:05:10 AEST 1990
In article <464 at spader.UUCP> lab at spader.UUCP (Lars Berntzon) writes:
> My problem is that i want to initialize two types of struct variables with
> the address of the opposit struct.
> static a = {&b, data ...};
> static b = {&a, other data...};
Deja vu... I quote from <18201:Sep2203:25:3190 at kramden.acf.nyu.edu>:
: > > static struct xtag x = {&y};
: > > static struct ytag y = {&x};
:
: A different approach should work under any C compiler, though it may not
: be implemented efficiently. It also has the usual syntactic problems of
: macros.
:
: static struct { struct xtag x; struct ytag y; }
: shmoe = { &(shmoe.y), &(shmoe.x) } ;
: #define x (shmoe.x)
: #define y (shmoe.y)
:
: Caveat: This is untested. But the idea is useful to remember.
I think the conclusion of the discussion was that there's no (other)
portable solution.
---Dan
More information about the Comp.lang.c
mailing list