Re: Using C++ Classes From D: dmd cannot link, while ldc segfault

2024-01-26 Thread zjh via Digitalmars-d-learn
On Friday, 26 January 2024 at 14:46:08 UTC, Emmanuel Danso Nyarko wrote: Yes, this is a project currently in progress. Vector was only working for windows but we have it working on linux but it's not yet ready to be used that's why you could only use it from a standalone fork. [here](https

Re: Using C++ Classes From D: dmd cannot link, while ldc segfault

2024-01-26 Thread Emmanuel Danso Nyarko via Digitalmars-d-learn
On Friday, 26 January 2024 at 13:40:12 UTC, Matheus Catarino wrote: On Friday, 26 January 2024 at 09:06:16 UTC, Emmanuel Danso Nyarko wrote: On Thursday, 25 January 2024 at 21:41:36 UTC, Matheus Catarino wrote: https://forum.dlang.org/post/kawfhminmtmwbmkzh...@forum.dlang.org On Monday, 19 Jun

Re: Using C++ Classes From D: dmd cannot link, while ldc segfault

2024-01-26 Thread Matheus Catarino via Digitalmars-d-learn
On Friday, 26 January 2024 at 09:06:16 UTC, Emmanuel Danso Nyarko wrote: On Thursday, 25 January 2024 at 21:41:36 UTC, Matheus Catarino wrote: https://forum.dlang.org/post/kawfhminmtmwbmkzh...@forum.dlang.org On Monday, 19 June 2023 at 06:11:59 UTC, mw wrote: LDC - the LLVM D compiler (1.32.2)

Re: Using C++ Classes From D: dmd cannot link, while ldc segfault

2024-01-26 Thread Emmanuel Danso Nyarko via Digitalmars-d-learn
On Thursday, 25 January 2024 at 21:41:36 UTC, Matheus Catarino wrote: https://forum.dlang.org/post/kawfhminmtmwbmkzh...@forum.dlang.org On Monday, 19 June 2023 at 06:11:59 UTC, mw wrote: LDC - the LLVM D compiler (1.32.2): ``` main.d(32): Error: undefined identifier `vector` in module `core.st

Using C++ Classes From D: dmd cannot link, while ldc segfault

2024-01-25 Thread Matheus Catarino via Digitalmars-d-learn
https://forum.dlang.org/post/kawfhminmtmwbmkzh...@forum.dlang.org On Monday, 19 June 2023 at 06:11:59 UTC, mw wrote: LDC - the LLVM D compiler (1.32.2): ``` main.d(32): Error: undefined identifier `vector` in module `core.stdcpp.vector`, did you mean enum member `MIctor`? ``` So what's wrong

Re: Using C++ Classes From D: dmd cannot link, while ldc segfault

2023-06-18 Thread mw via Digitalmars-d-learn
If I use array: ``` extern(C++) { void getInts(core.stdcpp.array.array!(int, 10) vec) { foreach (int i; 0 .. 10) { vec.at(i) = i; } } } ``` ``` #include using namespace std; void getInts(array* vector); ``` Both DMD and LDC has link error: base.cpp:42: undefined reference to `getIn

Re: Using C++ Classes From D: dmd cannot link, while ldc segfault

2023-06-18 Thread mw via Digitalmars-d-learn
On Monday, 19 June 2023 at 05:56:54 UTC, Richard (Rikki) Andrew Cattermole wrote: On 19/06/2023 5:54 PM, mw wrote: Ha, I saw vector.d there, So I can use this vector.d as the D side of C++'s std::vector? Probably, I just don't know how well tested it is. But worth a go! ``` import core.stdc

Re: Using C++ Classes From D: dmd cannot link, while ldc segfault

2023-06-18 Thread Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
On 19/06/2023 5:54 PM, mw wrote: Ha, I saw vector.d there, So I can use this vector.d as the D side of C++'s std::vector? Probably, I just don't know how well tested it is. But worth a go!

Re: Using C++ Classes From D: dmd cannot link, while ldc segfault

2023-06-18 Thread mw via Digitalmars-d-learn
On Monday, 19 June 2023 at 05:46:13 UTC, Richard (Rikki) Andrew Cattermole wrote: On 19/06/2023 5:39 PM, mw wrote: Then it will be very tedious, esp. for such library class std::list. Yes, you would also need to verify it with every compiler you need (MSVC, vs linux gcc). There could be a

Re: Using C++ Classes From D: dmd cannot link, while ldc segfault

2023-06-18 Thread Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
On 19/06/2023 5:39 PM, mw wrote: Then it will be very tedious, esp. for such library class std::list. Yes, you would also need to verify it with every compiler you need (MSVC, vs linux gcc). There could be a reason why it isn't in https://github.com/dlang/dmd/tree/master/druntime/src/core

Re: Using C++ Classes From D: dmd cannot link, while ldc segfault

2023-06-18 Thread mw via Digitalmars-d-learn
On Monday, 19 June 2023 at 05:39:51 UTC, mw wrote: Then it will be very tedious, esp. for such library class std::list. Is there a tool that can automate this? A related question: basically I want to pass an array of objects from D side to the Cpp side, is there any example showing how to

Re: Using C++ Classes From D: dmd cannot link, while ldc segfault

2023-06-18 Thread mw via Digitalmars-d-learn
On Monday, 19 June 2023 at 05:32:23 UTC, Richard (Rikki) Andrew Cattermole wrote: This is just a guess, but I think the problem is the vtable is incomplete. Because of this the offsets are wrong. So you wouldn't be calling push_back. So, you mean on the D side, it need to list all the fields

Re: Using C++ Classes From D: dmd cannot link, while ldc segfault

2023-06-18 Thread Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
This is just a guess, but I think the problem is the vtable is incomplete. Because of this the offsets are wrong. So you wouldn't be calling push_back.

Using C++ Classes From D: dmd cannot link, while ldc segfault

2023-06-18 Thread mw via Digitalmars-d-learn
Hi, I'm following this example: https://dlang.org/spec/cpp_interface.html#using_cpp_classes_from_d and try to wrap a std::list base.cpp ```cpp #include #include using namespace std; class Base { public: virtual void print3i(int a, int b, int c) = 0; }; class Derived : public B