digitalmars.D.bugs - [Issue 17081] New: Bodies in extern cpp functions in D files are not
- via Digitalmars-d-bugs (41/41) Jan 09 2017 https://issues.dlang.org/show_bug.cgi?id=17081
https://issues.dlang.org/show_bug.cgi?id=17081 Issue ID: 17081 Summary: Bodies in extern cpp functions in D files are not linked Product: D Version: D2 Hardware: x86_64 OS: Linux Status: NEW Severity: normal Priority: P1 Component: dmd Assignee: nobody puremagic.com Reporter: alexandru.razvan.c gmail.com While trying to interface C++ with D I noticed the bodies for external c++ functions in D files are not linked. For example I have the following files: // D Source import core.stdcpp.typeinfo; import core.stdc.string:strcmp; extern (C++) void fun(type_info ti) { assert(strcmp(ti.name(), "i") == 0); } // C++ Source #include <typeinfo> extern void fun(std::type_info *ti); int main() { fun(&typeid(int)); } When trying to compile and link the 2 objects I get the following error: " undefined reference to `std::type_info::name() const'". To solve this I edited druntime/src/core/stdcpp/typinfo.d and actually took the GNU libcpp implementation and translated it. Now instead of "final const(char)* name();" we actually have a full implementation: final const(char)* name()() const nothrow { return _name[0] == '*' ? _name + 1 : _name; } Using this seems to solve the problem. I propose actually implementing all non-virtual functions from druntime/src/core/stdcpp in order to solve this. --
Jan 09 2017