[LLVMdev] Variable declarations vs. definitions

Chris Lattner clattner at apple.com
Sat Jan 9 22:46:14 PST 2010


On Jan 9, 2010, at 9:31 PM, Dustin Laurence wrote:

> On 01/09/2010 01:12 PM, Chris Lattner wrote:
> 
>> The equivalent of "extern int G;" is:
>> 
>> @G = external global i32
> 
> Hmm.  Is it really?

Yes.

>   But this

> extern int x;
> 
> int x = 5;


The equivalent of that is:

@x = global i32 5

I made no claim that 'external' in LLVM has the same semantics as 'extern' in C.

> The difference is crucial, because I want to put
> 
> "@foo = external global i32"
> 
> in a header file that is then #included in every module where it is
> used, *including the defining module* (for a consistency check, and


LLVM IR is not C, and it is not designed for #includes or other related horrible C constructs.

-Chris





More information about the llvm-dev mailing list