[LLVMdev] Linking two external linkage GlobalValues

Ralph Corderoy ralph at inputplus.co.uk
Sat May 26 13:16:35 PDT 2007

Hi Anton,

> This is bug in the source code. You have two symbols with the same
> name in the different object files, which is definite redefinition. At
> least one of them should be declared with "extern".

C allows this.

    $ head foo.c bar.c
    ==> foo.c <==
    void bar();
    int foo;

    int main()
        return foo;

    ==> bar.c <==
    int foo;

    void bar()
        foo = 42;
    $ gcc -Wall foo.c bar.c && ./a.out; echo $?

Better practice to have one definition I agree, but it's valid C.



More information about the llvm-dev mailing list