digitalmars.D.learn - Nested C++ namespace library linking
- Guillaume Chatelet (24/24) Jan 20 2015 Consider the following foo.cpp
- Paul O'Neil (6/30) Jan 20 2015 Looks like a bug to me.
- Guillaume Chatelet (4/4) Jan 20 2015 That's what I thought.
- Kagamin (2/2) Jan 21 2015 You can ask to add a keyword to bugzilla for C++ issues, this can
- John Colvin (5/29) Jan 21 2015 Looks like a bug to me, for sure.
- Guillaume Chatelet (7/10) Jan 21 2015 Thx John,
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());
Jan 20 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
Jan 20 2015
That's what I thought. I reported this bug a while ago but it didn't get a lot of attention. https://issues.dlang.org/show_bug.cgi?id=13337
Jan 20 2015
You can ask to add a keyword to bugzilla for C++ issues, this can help to improve their visibility and searchability.
Jan 21 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, for sure.
In the mean-time you may be able to use some pragma(mangle, ...)
hacks to force the compiler to emit the right symbols.
Jan 21 2015
On Wednesday, 21 January 2015 at 14:59:15 UTC, John Colvin wrote:Looks like a bug to me, for sure. In the mean-time you may be able to use some pragma(mangle, ...) hacks to force the compiler to emit the right symbols.Thx John, extern(C++, A.B) { struct Type {} pragma(mangle,"_ZN1A1B3fooENS0_4TypeE") int foo(Type unused); } is indeed linking correctly :)
Jan 21 2015









"Kagamin" <spam here.lot> 