Path: utzoo!attcan!uunet!cs.utexas.edu!tut.cis.ohio-state.edu!pt.cs.cmu.edu!pt!dld From: dld@F.GP.CS.CMU.EDU (David Detlefs) Newsgroups: comp.lang.c++ Subject: Re: extern - when to use it Message-ID: Date: 30 Jul 89 21:12:34 GMT References: <6420@columbia.edu> <9702@alice.UUCP> Organization: CMU CS Department Lines: 26 In-reply-to: ark@alice.UUCP's message of 29 Jul 89 15:14:20 GMT I discovered recently in using G++ that Tiemann has implemented 'extern "C"' so that structure declarations occuring with them do not become part of the namespace in the same way that they do in C++ linkage. That is, if you write extern "C" { struct foo { int i; } } then later in the code "foo" is not recognized as a type name -- instead you must (as in C) use "struct foo". At first I thought this was a bug, because I had seen no mention of this behavior, but when it was explained to me that this is a feature, it began to seem like a great idea. It solves a number of problems, the chief of which is when a standard C header file declares a structure and a function with the same name. Cases I've found in our BSD4.3-type system include "timezone" and "wait". So, is this part of C++ 2.0? I could not find any reference to this feature in either Lippman's C++ Primer or Stroustrup's "Type-safe Linkage" paper. Are there any drawbacks to this that I (and Michael Tiemann, I guess) don't see? If not, is there any chance it will become part of the language specification? -- Dave Detlefs Any correlation between my employer's opinion Carnegie-Mellon CS and my own is statistical rather than causal, dld@cs.cmu.edu except in those cases where I have helped to form my employer's opinion. (Null disclaimer.)