Re: D and C++ undefined reference when namespace

2018-03-09 Thread Markus via Digitalmars-d
On Thursday, 8 March 2018 at 21:14:36 UTC, Steven Schveighoffer wrote: On 3/8/18 2:01 PM, Steven Schveighoffer wrote: On 3/8/18 1:56 PM, Markus wrote: I tested dmd (2.079.0), gdc and ldc2. All got the same result. Which makes me think, that it's not a bug, but a "feature" :) This is

Re: D and C++ undefined reference when namespace

2018-03-08 Thread Steven Schveighoffer via Digitalmars-d
On 3/8/18 2:01 PM, Steven Schveighoffer wrote: On 3/8/18 1:56 PM, Markus wrote: I tested dmd (2.079.0), gdc and ldc2. All got the same result. Which makes me think, that it's not a bug, but a "feature" :) This is DEFINITELY a bug. https://issues.dlang.org/show_bug.cgi?id=18582 -Steve

Re: D and C++ undefined reference when namespace

2018-03-08 Thread Steven Schveighoffer via Digitalmars-d
On 3/8/18 1:56 PM, Markus wrote: You are right. $ dmd -c main.d $ nm main.o | grep some U _ZN4ns_a13some_functionEPN4ns_a7class_aE $ nm lib.o | grep some T _ZN4ns_a13some_functionEPNS_7class_aE But when i merge the main.d and other.d I get $ nm main.o | grep

Re: D and C++ undefined reference when namespace

2018-03-08 Thread Steven Schveighoffer via Digitalmars-d
On 3/8/18 1:56 PM, Markus wrote: I tested dmd (2.079.0), gdc and ldc2. All got the same result. Which makes me think, that it's not a bug, but a "feature" :) This is DEFINITELY a bug. -Steve

Re: D and C++ undefined reference when namespace

2018-03-08 Thread kinke via Digitalmars-d
On Thursday, 8 March 2018 at 18:56:04 UTC, Markus wrote: I tested dmd (2.079.0), gdc and ldc2. All got the same result. Which makes me think, that it's not a bug, but a "feature" :) C++ mangling is part of the DMD front-end shared by all 3 compilers, so no surprises there:

Re: D and C++ undefined reference when namespace

2018-03-08 Thread Markus via Digitalmars-d
On Thursday, 8 March 2018 at 17:04:02 UTC, Steven Schveighoffer wrote: On 3/8/18 11:35 AM, Markus wrote: When I do this locally on my mac, I get a similar error. When I nm the main.o file vs. the lib.o file, I see different mangled names. It appears that the D mangled name is not doing back

Re: D and C++ undefined reference when namespace

2018-03-08 Thread Steven Schveighoffer via Digitalmars-d
On 3/8/18 11:35 AM, Markus wrote: error: main.o: In function `_Dmain': main.d:(.text._Dmain[_Dmain]+0xa): undefined reference to `ns_a::some_function(ns_a::class_a*)' collect2: error: ld returned 1 exit status Error: linker exited with status 1 symbols: nm --demangle libissue.so |

Re: D and C++ undefined reference when namespace

2018-03-08 Thread Steven Schveighoffer via Digitalmars-d
On 3/8/18 11:23 AM, Markus wrote: On Thursday, 8 March 2018 at 15:27:31 UTC, Markus wrote: Hi I got the following c++ code [lib.cpp]: namespace ns_a {   class class_a {   };   void some_function(class_a*) {;} } and the following d code [main.d]: extern (C++, namespace_a) {     class class_a

Re: D and C++ undefined reference when namespace

2018-03-08 Thread Markus via Digitalmars-d
On Thursday, 8 March 2018 at 16:19:40 UTC, Steven Schveighoffer wrote: On 3/8/18 10:27 AM, Markus wrote: Hi I got the following c++ code [lib.cpp]: namespace ns_a {   class class_a {   };   void some_function(class_a*) {;} } and the following d code [main.d]: extern (C++, namespace_a) {

Re: D and C++ undefined reference when namespace

2018-03-08 Thread Markus via Digitalmars-d
On Thursday, 8 March 2018 at 15:27:31 UTC, Markus wrote: Hi I got the following c++ code [lib.cpp]: namespace ns_a { class class_a { }; void some_function(class_a*) {;} } and the following d code [main.d]: extern (C++, namespace_a) { class class_a {} void some_function(class_a);

Re: D and C++ undefined reference when namespace

2018-03-08 Thread Steven Schveighoffer via Digitalmars-d
On 3/8/18 10:27 AM, Markus wrote: Hi I got the following c++ code [lib.cpp]: namespace ns_a {   class class_a {   };   void some_function(class_a*) {;} } and the following d code [main.d]: extern (C++, namespace_a) { did you mean ns_a? -Steve

D and C++ undefined reference when namespace

2018-03-08 Thread Markus via Digitalmars-d
Hi I got the following c++ code [lib.cpp]: namespace ns_a { class class_a { }; void some_function(class_a*) {;} } and the following d code [main.d]: extern (C++, namespace_a) { class class_a {} void some_function(class_a); } void main() { namespace_a.class_a instance_a;