Nested C++ namespace library linking

Paul O'Neil via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Tue Jan 20 14:06:38 PST 2015


On Tuesday, 20 January 2015 at 21:10:59 UTC, Guillaume Chatelet 
wrote:
> Consider the following foo.cpp
>
> namespace A {
> namespace B {
>   struct Type {};
>   int foo(Type unused){ return 42; }
> }
> }
>
> Compile it : g++ foo.cpp -c -o foo.o
>
> Then the following main.d
>
> extern(C++, A.B) {
>   struct Type {}
>   int foo(Type unused);
> }
>
> void main() {
>   foo(Type());
> }
>
> Compile it : dmd main.d foo.o
> It fails with : undefined reference to « A::B::foo(A::Type) »
>
> It looks like the Type is not resolved in the right namespace. 
> A::Type instead of A::B::Type. Did I miss something or is this 
> a bug ?
>
> I also tried fully qualifying foo and Type but I end up with 
> the exact same error :
>   A.B.foo(A.B.Type());

Looks like a bug to me.

---
Paul O'Neil
Github / IRC: todayman


More information about the Digitalmars-d-learn mailing list