[LLVMdev] global question
Eli Friedman
eli.friedman at gmail.com
Sat Mar 7 11:57:58 PST 2009
On Sat, Mar 7, 2009 at 10:44 AM, Patrick Boettcher
<patrick.boettcher at desy.de> wrote:
> Please correct me if I'm wrong, but how can the compiler know, that x is
> not initialized in another file which defines x as extern? It can only be
> sure, when x is declared static.
That's technically illegal in pure standard C, but yes, another file
with "int x = 10;" would override the definition in gcc.
> (I even remember someone, that it is platform specific whether x is
> initialized to 0 or not... or was it a question of C89 or C99?)
It's definitely initialized to zero; it's what the standard calls a
tentative definition. See C99 6.9.2p2.
-Eli
More information about the llvm-dev
mailing list