[LLVMdev] global question

John Regehr regehr at cs.utah.edu
Sat Mar 7 11:10:31 PST 2009


> 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.

I don't think you can attach an initializer to an extern except at the 
point where the variable is defined.  But since x is defined here, there 
would then be two definitions of x, a link-time error.

> (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?)

Definitely initialized to zero.

John



More information about the llvm-dev mailing list