Correct or Not or Old-fashioned or Bug
Richard Caley
rjc at cstr.ed.ac.uk
Fri May 24 04:18:18 AEST 1991
In article <ZHOUMI.91May23102519 at marlboro.nff.ncl.omron.co.jp>, Zhou Mi (zm) writes:
zm> But, there are so many conflicting answers that I feel really
zm> confusion. Can anyone give me a proper conclusion or answer ??
Me too, so I caved in and asked for divine guidence.
>From K&R, K&R-II and Plaughter and Brodie...
The Old testament, the book of Reference, chapter 11, verse 2:
``The apearence of the extern keyword in an external
definition indicates that storage for the identifiers being
declared will be allocated in another file. Thus in a
multi-file program, an external data definition without the
extern specifier must appear in exactly one of the files.''
The New Testament, the book of Reference, chapter 10, verse 2:
``An external object declaration that does not have an
initialiser, and does not contain the extern specifier, is a
tentative definition. [...] If no definition for the object
appears _in_the_translation_unit_, all its tentative
definitions become a single definition with initialiser 0.''
[emphasis mine].
The Commentaries:
``If a data object declaration is a tentative definition and you
write no definition for the same object later in the
translation unit, then the translater allocates storage for
the data object at the end of the translation unit.''
Someone else will have to do the Tablets of Stone.
TNT adds a comment that the multi-file version of the rule is
recognised by the standard as a common extension.
--
rjc at cstr.ed.ac.uk It was news to me too, too long on Unix.
More information about the Comp.lang.c
mailing list