Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/5/84; site mnetor.UUCP Path: utzoo!utcs!mnetor!george From: george@mnetor.UUCP (George Hart) Newsgroups: net.lang.c Subject: Re: Re: 4.2 extern a DISASTER (Flame) Message-ID: <1342@mnetor.UUCP> Date: Wed, 17-Jul-85 11:01:03 EDT Article-I.D.: mnetor.1342 Posted: Wed Jul 17 11:01:03 1985 Date-Received: Wed, 17-Jul-85 12:18:40 EDT References: <2643@hplabsc.UUCP> <1281@eagle.UUCP> <1282@eagle.UUCP> Distribution: net Organization: Computer X (CANADA) Ltd., Toronto, Ontario, Canada Lines: 69 > An addendum to my previous note. Dennis Ritchie has commented in this forum on > the suitability of the strict interpretation of my last example. In a > nutshell, he said that it was a mistake to put it in the manual at all, and > it was there for a single machine (Honeywell running GCOS) whose linker had > arbitrary restrictions on the use of common symbols. I'm not sure exactly > what the ANSI (draft) standard says on this matter, as I don't have my copy > handy. > -- > Marty Shannon > UUCP: ihnp4!eagle!mjs > Phone: +1 201 522 6063 Excerpts from the 84 04 26 Draft ANSI C Standard. (It seems as if the standard is saying the compilers which resolve the variables in your last example to the same location are doing it right! Please correct me if I'm misinterpreting things.) ============================= Section 7.2, "External data definition" "A declaration of the identifier of an object with an initializer constitutes the DEFINITION of the object (i.e., that declaration for which the storage is allocated. A declaration of the identifier of an object without an initializer and ----------------------------------------------------------------------- without the keyword "extern" constitutes a TENTATIVE DEFINITION. If a ---------------------------------------------------------------------- definition is encountered , all tenative definitions are taken to be -------------------------------------------------------------------- declarations of the same object (subject to the linkage rules of ---------------------------------------------------------------- Section 2.2.1). If no subsequent definition is encountered, the first ---------------------------------------------------------------------- tenative definition is taken to be a definition with initializer equal --------------------------------------------------------------------- to 0. ----- A declaration of the identifier of an object without an initializer and with the keyword "extern" requires that somewhere in the entire program there must be exactly one definition for the identifier." From Section 2.2.1 "Scopes and linkages of identifiers" ...In the set of source files and libraries that constitutes an entire program, every instance of an identifier with external linkage denotes ------------------------------------------------------------- the same function or object.... ---------------------------- ...For an identifier of a function or object declared with file scope, if the lexically first declaration in the source file contains the keyword "static", the identifier has internal linkage. Otherwise the ------------- identifier has external linkage.... -------------------------------- ============================== -- Regards, George Hart, Computer X Canada Ltd. UUCP: {allegra|decvax|linus|ihnp4}!utzoo!mnetor!george BELL: (416)475-8980