discussion on the forum:
https://forum.dlang.org/post/[email protected]
If there is a namespace that is declared in 2 different files, and a function in the namespace in one file uses a type from the same namespace from another file, instead of using a backreference (sequence id) in the name mangling for the namespace of the parameter, it is incorrectly spelled out.
example:
lib.cpp:
namespace thenamespace
{
class class_a {
};
void some_function(class_a*) {;}
}
other.d:
extern (C++, thenamespace) {
class class_a {}
}
main.d:
import other;
extern (C++, thenamespace) {
void some_function(class_a);
}
void main() {
class_a instance_a;
thenamespace.some_function(instance_a);
}
build via:
g++ -c lib.cpp
dmd main.d other.d lib.o
Linker error:
Undefined symbols for architecture x86_64:
"thenamespace::some_function(thenamespace::class_a*)", referenced from:
__Dmain in main.o
If I use nm I see:
in main.o:
U __ZN12thenamespace13some_functionEPN12thenamespace7class_aE
in lib.o:
T __ZN12thenamespace13some_functionEPNS_7class_aE
Note the back reference S_ near the end of the symbol. I believe the reason it doesn't happen for D's C++ mangler is because even though the namespace is identical, it's a different D symbol from a different module.
This is shown by moving the declaration of class_a from other.d into main.d, and compilation succeeds.
Comment #1 by pro.mathias.lang — 2018-06-08T04:16:40Z
Oh I missed this when I opened 18922. It's fixed now, so marking this as duplicate.
*** This issue has been marked as a duplicate of issue 18922 ***
Comment #2 by contact — 2018-06-13T12:07:40Z
(In reply to Mathias LANG from comment #1)
> Oh I missed this when I opened 18922. It's fixed now, so marking this as
> duplicate.
>
> *** This issue has been marked as a duplicate of issue 18922 ***
You are awesome! Thanks a lot!