digitalmars.D - interfacing c++ templates. Another c++-namespace issue?
- Markus (53/53) Mar 16 2018 Hi
- Walter Bright (5/7) Mar 16 2018 Might check that this https://issues.dlang.org/show_bug.cgi?id=17772 is ...
- Steven Schveighoffer (11/22) Mar 16 2018 There was another namespace issue recently found:
- H. S. Teoh (8/22) Mar 16 2018 [...]
Hi [template.cpp]: template<typename Type> void some_templated_function(); template<> void some_templated_function<int>() {} [main.d]: extern(C++) { void some_templated_function(Type)(); } void main() { some_templated_function!int; } compilation: g++ -c template_with_ns.cpp dmd main.d template.o this WORKS! :) BUT, now I put all c++ stuff into a namespace [template_with_ns.cpp]: namespace some_namespace { template<typename Type> void some_templated_function(); template<> void some_templated_function<int>() {} } [main_with_ns.d]: extern(C++, some_namespace) { void some_templated_function(Type)(); } void main() { some_templated_function!int; } DOES NOT compile undefined reference to `void some_templated_function<int>()' nm main_with_ns.o _Z23some_templated_functionIiEvv nm template_with_ns.o _ZN14some_namespace23some_templated_functionIiEEvv It seems like dmd doesn't care about the namespace of the template. Can someone confirm this as a bug? or am I doing something terrible wrong? :) When I retry this with gdc it doesn't compile. Neither with namespace nor without: nm template.o: _Z23some_templated_functionIiEvv main.o: _ZN23some_templated_functionIiE23some_templated_functionEv The more I work with D, interfacing C++, the more I start to know "mangling" :D Have fun Markus
Mar 16 2018
On 3/16/2018 11:57 AM, Markus wrote:It seems like dmd doesn't care about the namespace of the template. Can someone confirm this as a bug? or am I doing something terrible wrong? :)Might check that this https://issues.dlang.org/show_bug.cgi?id=17772 is not the issue. See my comment in https://github.com/dlang/dmd/pull/7906 : "Fixing the T_ mangling is much more problematic, I don't know how to do that yet. This namespace issue is independent, so it is convenient to do it separately."
Mar 16 2018
On 3/16/18 3:32 PM, Walter Bright wrote:On 3/16/2018 11:57 AM, Markus wrote:There was another namespace issue recently found: https://issues.dlang.org/show_bug.cgi?id=18582 But it looks like its different. When you compare: C++: _ZN14some_namespace23some_templated_functionIiEEvv D: _ZN23some_templated_functionIiE23some_templated_functionEv Something is wrong. Instead of the namespace, you get "some_templated_function" as the namespace! -SteveIt seems like dmd doesn't care about the namespace of the template. Can someone confirm this as a bug? or am I doing something terrible wrong? :)Might check that this https://issues.dlang.org/show_bug.cgi?id=17772 is not the issue. See my comment in https://github.com/dlang/dmd/pull/7906 : "Fixing the T_ mangling is much more problematic, I don't know how to do that yet. This namespace issue is independent, so it is convenient to do it separately."
Mar 16 2018
On Fri, Mar 16, 2018 at 03:53:00PM -0400, Steven Schveighoffer via Digitalmars-d wrote: [...]There was another namespace issue recently found: https://issues.dlang.org/show_bug.cgi?id=18582 But it looks like its different. When you compare: C++: _ZN14some_namespace23some_templated_functionIiEEvv D: _ZN23some_templated_functionIiE23some_templated_functionEv Something is wrong. Instead of the namespace, you get "some_templated_function" as the namespace![...] I wonder if the problem is caused by wrongly treating the template function as a D eponymous template instead of a C++ template? T -- Don't drink and derive. Alcohol and algebra don't mix.
Mar 16 2018