Path: utzoo!attcan!uunet!auspex!guy From: guy@auspex.UUCP (Guy Harris) Newsgroups: comp.lang.c Subject: Re: Debugging, statics. Keywords: C style static initialization Message-ID: <774@auspex.UUCP> Date: 21 Dec 88 22:36:31 GMT References: <421@aber-cs.UUCP> <127@mole-end.UUCP> Reply-To: guy@auspex.UUCP (Guy Harris) Distribution: eunet,world Organization: Auspex Systems, Santa Clara Lines: 50 >The difficulty in C is that you can't force an instance of a struct to >be initialized when it is declared, especially if it is declared >locally. Err, umm, better make that "*only* if it declared locally". There's no particular problem with struct foo { int a; char *b; float c; } bar = { 666, "Hello, sailor!", 137.06 }; if "bar" is "static" or "external". >Because there is no automatic aggregate initialization, Automatic initialization is often (always?) just syntactic sugar. You can do foo() { int a = 33; struct foo b = { 666, "Hello, sailor!", 137.06}; ... } by doing foo() { int a = 33; struct foo b; b.a = 666; b.b = "Hello, sailor!"; b.c = 137.06; ... } The problem here appears to be that C makes it inconvenient to have non-automatic, private data that belongs to an *instance* of the generator; there's only one copy of a "static", so you don't get one per customer. (C doesn't make it *impossible*, of course.)