3.7.2 External Object Definitions
Eyal Lebedinsky
eyal at echo.canberra.edu.au
Wed Feb 6 22:37:00 AEST 1991
G'day
I have a situation where two static structures at the external level
are defined and initialized to each have a member pointer to the other.
My problem is finding the proper ANSI declarations/definitions for this
case.
It is obvious that the second object defined should first have a
forward declaration for the first object to be properly initialized.
Maybe a sketch will do here:
<linkage> struct x i7;
static struct x i6 = { &i7 };
<linkage> struct x i7 = { &i6 };
Now, the <linkage> is what I find different compilers have different
expectations of. ANSI 3.7.2 is where I looked for the answer. I tried
gnu (1.39) which I hope is ANSI by now. It likes this one:
(1) extern int i7;
(2) static int i7 = 1;
It hates this one:
static int i7; /* tentative definition, internal linkage */
(3) extern int i7 = 1;
Microsoft 5.1 likes both, but I wouldn't trust it much.
Q: what should the comment on the right say for (1,2,3) in the sense on
the examples at the end of 3.7.2? What I want is to first give a
'tentative definition' or a 'declaration' followed later by the
initialized 'definition'.
I know how shady this area is with traditional compilers and do not wish to
discuss it, so please limit replies to ANSI issues.
More information about the Comp.std.c
mailing list