Correct or Not or Old-fashioned or Bug

Christopher R Volpe volpe at camelback.crd.ge.com
Thu May 23 01:43:21 AEST 1991


In article <1991May21.150735.12200 at convex.com>, grogers at convex.com
(Geoffrey Rogers) writes:
|>In non-ANSI C compiler/loader environments this may or may not work. You
|>could get multiple defined symbols for i, depending upon the model that the
|>compiler used for external variables.
|>
|>The above code in not ANSI conforming, because you do have multiple
|>definitions of i.

I think so far I have seen about 3 or 4 wrong answers to this question, such
as the above. There is nothing wrong with the referenced code as far as
the Standard is concerned. There are not multiple definitions of i, because
none of those *tentative* definitions has an initializer. In such a
situation, all tentative definitions are treated as a single definition
with initializer 0. (See A10.2 in K&R2 for an explanation)

-Chris

|>+------------------------------------+---------------------------------+
|>| Geoffrey C. Rogers   		     | "Whose brain did you get?"      |
|>| grogers at convex.com                 | "Abbie Normal!"                 |
|>| {sun,uunet,uiucdcs}!convex!grogers |                                 |
|>+------------------------------------+---------------------------------+
                                                                       
==================
Chris Volpe
G.E. Corporate R&D
volpecr at crd.ge.com



More information about the Comp.lang.c mailing list