Re: A question about C++ interop

2020-03-29 Thread YD via Digitalmars-d-learn
On Sunday, 29 March 2020 at 17:32:59 UTC, kinke wrote: On Sunday, 29 March 2020 at 15:20:52 UTC, YD wrote: So what do I need to declare in the D file for it to match the library entry? Thanks! This is similar to https://issues.dlang.org/show_bug.cgi?id=19260, and can be worked around the

Re: A question about C++ interop

2020-03-29 Thread kinke via Digitalmars-d-learn
On Sunday, 29 March 2020 at 15:20:52 UTC, YD wrote: So what do I need to declare in the D file for it to match the library entry? Thanks! This is similar to https://issues.dlang.org/show_bug.cgi?id=19260, and can be worked around the same way by messing manually with the mangled name, if

Re: A question about C++ interop

2020-03-29 Thread YD via Digitalmars-d-learn
On Sunday, 29 March 2020 at 15:20:52 UTC, YD wrote: On Sunday, 29 March 2020 at 01:50:24 UTC, evilrat wrote: [...] Thanks, dummy placeholder works. But there is a new problem on Windows, let's say there are two classes in C++: [...] Actually I found that if I create a C wrapper like

Re: A question about C++ interop

2020-03-29 Thread YD via Digitalmars-d-learn
On Sunday, 29 March 2020 at 01:50:24 UTC, evilrat wrote: ... Same here, STL bindings is not yet finished. If you don't need that method specifically, just replace it with a dummy. Or make your own bindings. Thanks, dummy placeholder works. But there is a new problem on Windows, let's say

Re: A question about C++ interop

2020-03-28 Thread evilrat via Digitalmars-d-learn
On Saturday, 28 March 2020 at 19:14:38 UTC, YD wrote: Hi, now I have a further question: when the C++ class A actually has a method that looks like virtual void get_info(std::string ) const = 0; in order to preserve the virtual function table layout (I found that if I omit this

Re: A question about C++ interop

2020-03-28 Thread YD via Digitalmars-d-learn
On Saturday, 28 March 2020 at 07:33:38 UTC, Jacob Carlborg wrote: On 2020-03-27 20:17, YD wrote: Hi, I have a C++ header file which looks like     class A {     public:     static A *create();     virtual int f() const = 0;     }; And there is a C++ library file which provides

Re: A question about C++ interop

2020-03-28 Thread YD via Digitalmars-d-learn
On Saturday, 28 March 2020 at 07:33:38 UTC, Jacob Carlborg wrote: On 2020-03-27 20:17, YD wrote: [...] Classes in D are always passed by reference. Try dropping the pointer in the `create` method: static A create(); Thanks! I got it to work for now.

Re: A question about C++ interop

2020-03-28 Thread Jacob Carlborg via Digitalmars-d-learn
On 2020-03-27 20:17, YD wrote: Hi, I have a C++ header file which looks like     class A {     public:     static A *create();     virtual int f() const = 0;     }; And there is a C++ library file which provides the implementation, so that if I write a C++ program and call