Path: utzoo!attcan!telly!lethe!yunexus!ists!helios.physics.utoronto.ca!news-server.csri.toronto.edu!bonnie.concordia.ca!uunet!zaphod.mps.ohio-state.edu!rpi!batcomputer!munnari.oz.au!manuel!csc.canberra.edu.au!echo!eyal From: eyal@echo.canberra.edu.au (Eyal Lebedinsky) Newsgroups: comp.std.c Subject: 3.7.2 External Object Definitions Summary: how to define mutualy referencing static structs. Keywords: external,linkage,declaration,definition Message-ID: Date: 6 Feb 91 11:37:00 GMT Sender: news@csc.canberra.edu.au Organization: Info Sci & Eng, University of Canberra Lines: 37 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: struct x i7; static struct x i6 = { &i7 }; struct x i7 = { &i6 }; Now, the 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.