Path: utzoo!utgpu!water!watmath!clyde!att!osu-cis!tut.cis.ohio-state.edu!mailrus!cornell!uw-beaver!tektronix!percival!littlei!donk!ajw From: ajw@donk.UUCP (ajw) Newsgroups: comp.lang.c Subject: static list initialization Message-ID: <196@donk.UUCP> Date: 14 Oct 88 22:07:36 GMT Distribution: na Organization: DTO, Intel Corporation; Hillsboro, OR Lines: 28 Here's a fragment of code I find myself staring at glumly from time to time. It sets up the nucleus of a 2-way list, into which extra malloc'd nodes will be inserted. struct whatever { struct whatever *next; /* next node */ struct whatever *prev; /* previous node */ int eresting_stuff; /* blah, blah, ... */ }; extern struct whatever tail; static struct whatever head = { &tail, (struct whatever *)0 }; static struct whatever tail = { (struct whatever *)0, &head }; Without the 'extern', the compiler can't initialize 'head'. But with it, I get a 'non-standard extension' warning, although everything works just fine. Question is, is there a way to achieve this initialization within the letter of the law, leaving 'head' and 'tail' both static? If you want to e-mail, please use addresses below. Ta muchly. -- Alan Waldock ...{tektronix|sun}!ogcvax!omepd!ihf1!mdt!ajw Intel Corp, HF2-37 OR ...uunet!littlei!ihf1!mdt!ajw 5200 NE Elam Young Pkwy OR EVEN ajw@mdt.hf.intel.com Hillsboro, OR. 97124-6497 OR IF ALL ELSE FAILS (503) 696-2478 Opinions individual author's. Read before breaking seal. No warranty implied.