<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><br><div><div>On May 5, 2010, at 2:32 PMPDT, Nathan Jeffords wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><div class="im"><br>
</div>Global definitions like "int x;" are treated as common to allow<br>
linking buggy programs that forget to use "extern" on declarations.</blockquote><div><br></div><div>Is this always the behavior, or only when certain options are set? This seems like a violation of the language standard.</div>
</div></blockquote><br></div><div>Technically yes; the original K&R C book had the one-definition rule in it.  Early C compilers did not work this way, however, and by the time that book was published (1978) there was already a large body of code that assumed the "common" model (also Ritchie's preference, I believe).  In practice most compilers still default to this model because a lot of widely used stuff will break if they don't, and the behavior is given in J.5.11 of C99 as a common extension.</div><div><br></div><div>Use -fno-common to turn it off.</div><div><br></div></body></html>