[LLVMdev] extern "C" and namespaces

Nick Lewycky nlewycky at google.com
Thu Sep 19 19:30:05 PDT 2013


On 19 September 2013 16:50, Riyaz Puthiyapurayil <
Riyaz.Puthiyapurayil at synopsys.com> wrote:

>  Can someone confirm whether the following is a known clang bug?
>

Yes, this was just fixed, literally minutes ago in r191064.

Nick


> I am having a lot of trouble compiling some old legacy code due to this
> error. I know “using namespace” is horrible but that doesn’t make it
> illegal (g++ accepts this). The fix is easy but there are just too many
> instances of this in the legacy code. The following is not from the code I
> am trying to compile but is derived from an example in the C++11 standard
> (7.3.4 note 6)****
>
> ** **
>
> *foo.cpp:*
>
> namespace A {****
>
>     extern "C" int g();****
>
>     extern "C++" int h();****
>
> }****
>
> namespace B {****
>
>     extern "C" int g();****
>
>     extern "C++" int h(int);****
>
> }****
>
> using namespace A;****
>
> using namespace B;****
>
> void f() {****
>
>     g(); // okay: name g refers to the same entity****
>
>     h(); // okay: overload resolution selects A::h****
>
> }****
>
> ** **
>
> foo.cpp:12:5: error: call to 'g' is ambiguous****
>
>     g(); // okay: name g refers to the same entity****
>
>     ^****
>
> foo.cpp:2:20: note: candidate function****
>
>     extern "C" int g();****
>
>                    ^****
>
> foo.cpp:6:20: note: candidate function****
>
>     extern "C" int g();****
>
>                    ^****
>
> 1 error generated.****
>
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20130919/079d3271/attachment.html>


More information about the llvm-dev mailing list