Re: Statically compiled binary with C interop crashes.

2024-04-18 Thread Steven Schveighoffer via Digitalmars-d-learn
On Thursday, 18 April 2024 at 11:05:07 UTC, yabobay wrote: On Wednesday, 17 April 2024 at 15:24:07 UTC, Ferhat Kurtulmuş wrote: On Wednesday, 17 April 2024 at 11:03:22 UTC, yabobay wrote: I'm using [dray](https://code.dlang.org/packages/dray) in my project with dub, here's the relevant parts of

Re: Statically compiled binary with C interop crashes.

2024-04-18 Thread yabobay via Digitalmars-d-learn
On Wednesday, 17 April 2024 at 15:24:07 UTC, Ferhat Kurtulmuş wrote: On Wednesday, 17 April 2024 at 11:03:22 UTC, yabobay wrote: I'm using [dray](https://code.dlang.org/packages/dray) in my project with dub, here's the relevant parts of the dub.json: [...] İt seems your issue is related to t

Re: Statically compiled binary with C interop crashes.

2024-04-17 Thread Ferhat Kurtulmuş via Digitalmars-d-learn
On Wednesday, 17 April 2024 at 11:03:22 UTC, yabobay wrote: I'm using [dray](https://code.dlang.org/packages/dray) in my project with dub, here's the relevant parts of the dub.json: [...] İt seems your issue is related to the raylib itself, neither the binding you use nor the d programming l

Statically compiled binary with C interop crashes.

2024-04-17 Thread yabobay via Digitalmars-d-learn
I'm using [dray](https://code.dlang.org/packages/dray) in my project with dub, here's the relevant parts of the dub.json: ```json "dependencies" : {"dray": "~>4.2.0-r3"}, "dflags-ldc": ["--static"], "lflags": ["-static"] ``` In my regular setup with Debian, i can compile and run my

Re: Using the Standard Library with C++ Interop

2021-02-05 Thread Bastiaan Veelo via Digitalmars-d-learn
On Friday, 5 February 2021 at 21:40:29 UTC, wolfiesnotfine wrote: In any case, I'm unsure how I would runtime init from C++. Is there a specific function I should call? https://dlang.org/phobos/core_runtime.html#.rt_init Could this be done at compile time in a consteval or constexpr function?

Re: Using the Standard Library with C++ Interop

2021-02-05 Thread wolfiesnotfine via Digitalmars-d-learn
On Friday, 5 February 2021 at 21:11:20 UTC, Adam D. Ruppe wrote: tbh I'd say just don't use betterC, you can still runtime init from C++ and be judicious in what features you use to keep it more minimal. Hmm. I'm mostly concerned about issues or slowdowns in mixing the manual memory managemen

Re: Using the Standard Library with C++ Interop

2021-02-05 Thread Adam D. Ruppe via Digitalmars-d-learn
On Friday, 5 February 2021 at 21:04:00 UTC, wolfiesnotfine wrote: however sse() from core.cpuid is incorrectly reporting as false. The function properly returns true if it's not called from C++ but instead a D main function. That makes me think it is a static constructor, and indeed there is

Using the Standard Library with C++ Interop

2021-02-05 Thread wolfiesnotfine via Digitalmars-d-learn
Hello, I'm currently working on a primarily C++ project but I wanted to leverage some of D's language features and library for a few parts. I'm using the betterC subset and here's the code snippet in D: https://run.dlang.io/is/XOXF06 It's quite a simple test, and the code just gets called from

Re: C++ interop, abstract struct problem

2020-12-29 Thread RSY via Digitalmars-d-learn
Here is a debugger view of the passed IAllocator& https://i.imgur.com/p04Tj4a.png

Re: C++ interop, abstract struct problem

2020-12-29 Thread RSY via Digitalmars-d-learn
Hmm, something seems to be very wrong, here what i got so far ``` D struct IAllocator { } struct DefaultAllocator { // BASE -- IAllocator base = IAllocator(); alias base this; // ubyte

Re: C++ interop, abstract struct problem

2020-12-28 Thread RSY via Digitalmars-d-learn
On Monday, 28 December 2020 at 16:42:19 UTC, Paul Backus wrote: On Monday, 28 December 2020 at 15:42:26 UTC, RSY wrote: ``IAllocator`` is an abstract struct, (a struct with virtual functions) But the problem is D doesn't allow that, so apparently i need to use an abstract class and wrap it us

Re: C++ interop, abstract struct problem

2020-12-28 Thread Paul Backus via Digitalmars-d-learn
On Monday, 28 December 2020 at 15:42:26 UTC, RSY wrote: ``IAllocator`` is an abstract struct, (a struct with virtual functions) But the problem is D doesn't allow that, so apparently i need to use an abstract class and wrap it using: ``extern (C++, struct)`` You could try using one of the t

Re: C++ interop, abstract struct problem

2020-12-28 Thread RSY via Digitalmars-d-learn
IAllocator struct: https://github.com/nem0/LumixEngine/blob/master/src/engine/allocator.h#L18 function: https://github.com/nem0/LumixEngine/blob/master/src/renderer/gpu/gpu.h#L208

C++ interop, abstract struct problem

2020-12-28 Thread RSY via Digitalmars-d-learn
Hello I try to use a C++ lib So far so good, i managed to use that lib and get started The problem however is this: C++ API: ``` void preinit(IAllocator& allocator, bool load_renderdoc); ``` ``IAllocator`` is an abstract struct, (a struct with virtual functions) But the problem is D does

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 sam

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 you

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 th

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 &s) const = 0; in order to preserve the virtual function table layout (I found that if I omit this functi

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 the

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    

A question about C++ interop

2020-03-27 Thread YD via Digitalmars-d-learn
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 auto *p = A::create(); std::cout <

Re: C++ Interop

2018-01-07 Thread Laeeth Isharc via Digitalmars-d-learn
On Saturday, 6 January 2018 at 11:17:56 UTC, Seb wrote: On Friday, 5 January 2018 at 13:02:12 UTC, qznc wrote: I'm exploring [0] C++ interop after watching Walter's presentation [1]. [...] I know about this: https://github.com/Remedy-Entertainment/binderoo https://github

Re: C++ Interop

2018-01-06 Thread Andres Clari via Digitalmars-d-learn
On Saturday, 6 January 2018 at 13:51:54 UTC, qznc wrote: It would be great to have std::vector and std::string out of the box in D, but putting it into druntime? Druntime is supposed to be shared among all frontends, isn't it? GCC and Clang probably do not have equivalent vector/string classes

Re: C++ Interop

2018-01-06 Thread qznc via Digitalmars-d-learn
On Saturday, 6 January 2018 at 11:20:01 UTC, Seb wrote: On Saturday, 6 January 2018 at 11:17:56 UTC, Seb wrote: On Friday, 5 January 2018 at 13:02:12 UTC, qznc wrote: I'm exploring [0] C++ interop after watching Walter's presentation [1]. [...] I know about this: https://github.

Re: C++ Interop

2018-01-06 Thread Mengu via Digitalmars-d-learn
On Friday, 5 January 2018 at 13:02:12 UTC, qznc wrote: I'm exploring [0] C++ interop after watching Walter's presentation [1]. I hit a block with classes as template parameters. This means vector works, but vector does not. D seems to map vector!Foo to vector. Likewise share

Re: C++ Interop

2018-01-06 Thread Seb via Digitalmars-d-learn
On Saturday, 6 January 2018 at 11:17:56 UTC, Seb wrote: On Friday, 5 January 2018 at 13:02:12 UTC, qznc wrote: I'm exploring [0] C++ interop after watching Walter's presentation [1]. [...] I know about this: https://github.com/Remedy-Entertainment/binderoo https://github

Re: C++ Interop

2018-01-06 Thread Seb via Digitalmars-d-learn
On Friday, 5 January 2018 at 13:02:12 UTC, qznc wrote: I'm exploring [0] C++ interop after watching Walter's presentation [1]. [...] I know about this: https://github.com/Remedy-Entertainment/binderoo https://github.com/dlang/druntime/pull/1802

Re: C++ Interop

2018-01-05 Thread Timothee Cour via Digitalmars-d-learn
see also https://github.com/Syniurge/Calypso/ although I'm having lots of issues using it on OSX On Fri, Jan 5, 2018 at 9:02 AM, qznc via Digitalmars-d-learn wrote: > I'm exploring [0] C++ interop after watching Walter's presentation [1]. > > I hit a block with classe

C++ Interop

2018-01-05 Thread qznc via Digitalmars-d-learn
I'm exploring [0] C++ interop after watching Walter's presentation [1]. I hit a block with classes as template parameters. This means vector works, but vector does not. D seems to map vector!Foo to vector. Likewise shared_ptr is a problem. Any way to fix that on the D side

Re: Status of Win32 C++ interop

2015-09-10 Thread Benjamin Thaut via Digitalmars-d-learn
On Tuesday, 8 September 2015 at 12:56:00 UTC, Laeeth Isharc wrote: This is really very clear and helpful, and I appreciate your taking the time. I will place it on the wiki if that's okay. Thats ok. Library support is surely one of the largest impediments to the adoption of D, and we ou

Re: C++ Interop -- Two Questions

2015-09-09 Thread Kagamin via Digitalmars-d-learn
On Wednesday, 9 September 2015 at 13:17:53 UTC, Mike Parker wrote: Yes, I get that. But how does that work when you're linking to a C++ library and the translation of the C++ class to D is an interface? Or is it possible now to link D classes directly with C classes? Classes and templates exc

Re: C++ Interop -- Two Questions

2015-09-09 Thread Mike Parker via Digitalmars-d-learn
On Wednesday, 9 September 2015 at 11:49:33 UTC, Kagamin wrote: Static functions are declared with `static` storage class. This looks so basic, it's even not documented in language spec, lol. Yes, I get that. But how does that work when you're linking to a C++ library and the translation of t

Re: C++ Interop -- Two Questions

2015-09-09 Thread Kagamin via Digitalmars-d-learn
Static functions are declared with `static` storage class. This looks so basic, it's even not documented in language spec, lol. In D classes are reference types by default.

Re: C++ Interop -- Two Questions

2015-09-09 Thread Jacob Carlborg via Digitalmars-d-learn
On 2015-09-09 11:55, Mike Parker wrote: Given a C++ class that looks like this: class Foo { static void Initialize(const SomeObject&); virtual void func1(); } The documentation at [1] doesn't say anything about how to handle static member functions like Initialize, nor do I see anythin

C++ Interop -- Two Questions

2015-09-09 Thread Mike Parker via Digitalmars-d-learn
Given a C++ class that looks like this: class Foo { static void Initialize(const SomeObject&); virtual void func1(); } The documentation at [1] doesn't say anything about how to handle static member functions like Initialize, nor do I see anything about references. I assume I can declar

Re: C++ Interop -- Two Questions

2015-09-09 Thread Mike Parker via Digitalmars-d-learn
On Wednesday, 9 September 2015 at 09:55:21 UTC, Mike Parker wrote: The documentation at [1] doesn't say anything about how to [1] http://dlang.org/cpp_interface.html

Re: Status of Win32 C++ interop

2015-09-08 Thread Kagamin via Digitalmars-d-learn
On Tuesday, 8 September 2015 at 12:56:00 UTC, Laeeth Isharc wrote: How does it work when external APIs expect objects from the C++ standard library? strings, and so on? How about funny pointer types? shared_ptr etc? std::vector, std::list? No, in current state nothing smart is supported.

Re: Status of Win32 C++ interop

2015-09-08 Thread Laeeth Isharc via Digitalmars-d-learn
On Monday, 7 September 2015 at 18:37:49 UTC, Benjamin Thaut wrote: On Friday, 4 September 2015 at 16:19:49 UTC, Laeeth Isharc wrote: Hi Benjamin Would you be able to give a little more colour on what the limits are of interoperability for C++ with DMD master or release ? As I understand it d

Re: Status of Win32 C++ interop

2015-09-08 Thread drug via Digitalmars-d-learn
On 08.09.2015 11:45, Benjamin Thaut wrote: On Monday, 7 September 2015 at 19:30:44 UTC, drug wrote: 07.09.2015 21:37, Benjamin Thaut пишет: snip So far I haven't found a situation where I couldn't make it work the way I wanted. Its just some work to write the D headers for the C++ classes and

Re: Status of Win32 C++ interop

2015-09-08 Thread Benjamin Thaut via Digitalmars-d-learn
On Monday, 7 September 2015 at 19:30:44 UTC, drug wrote: 07.09.2015 21:37, Benjamin Thaut пишет: snip So far I haven't found a situation where I couldn't make it work the way I wanted. Its just some work to write the D headers for the C++ classes and vise versa, because you have to duplicate

Re: Status of Win32 C++ interop

2015-09-07 Thread drug via Digitalmars-d-learn
07.09.2015 21:37, Benjamin Thaut пишет: snip So far I haven't found a situation where I couldn't make it work the way I wanted. Its just some work to write the D headers for the C++ classes and vise versa, because you have to duplicate everything once more. An automated tool for this would be n

Re: Status of Win32 C++ interop

2015-09-07 Thread Benjamin Thaut via Digitalmars-d-learn
On Friday, 4 September 2015 at 16:19:49 UTC, Laeeth Isharc wrote: Hi Benjamin Would you be able to give a little more colour on what the limits are of interoperability for C++ with DMD master or release ? As I understand it destructors and constructors don't work, and obviously it will get t

Re: Status of Win32 C++ interop

2015-09-04 Thread Szymon Gatner via Digitalmars-d-learn
On Friday, 4 September 2015 at 16:26:51 UTC, Kagamin wrote: On Friday, 4 September 2015 at 15:43:44 UTC, Szymon Gatner wrote: but now using phobos64.lib from 2.068 distribution does not even link properly with VC2015. That's https://issues.dlang.org/show_bug.cgi?id=14849 yup, that looks like

Re: Status of Win32 C++ interop

2015-09-04 Thread Kagamin via Digitalmars-d-learn
On Friday, 4 September 2015 at 15:43:44 UTC, Szymon Gatner wrote: but now using phobos64.lib from 2.068 distribution does not even link properly with VC2015. That's https://issues.dlang.org/show_bug.cgi?id=14849

Re: Status of Win32 C++ interop

2015-09-04 Thread Laeeth Isharc via Digitalmars-d-learn
On Friday, 4 September 2015 at 14:18:40 UTC, Benjamin Thaut wrote: On Friday, 4 September 2015 at 10:04:48 UTC, Szymon Gatner wrote: On Friday, 4 September 2015 at 09:27:14 UTC, Benjamin Thaut wrote: On Friday, 4 September 2015 at 09:07:39 UTC, Szymon Gatner wrote: What about 32bit phobos? La

Re: Status of Win32 C++ interop

2015-09-04 Thread Szymon Gatner via Digitalmars-d-learn
On Friday, 4 September 2015 at 14:18:40 UTC, Benjamin Thaut wrote: On Friday, 4 September 2015 at 10:04:48 UTC, Szymon Gatner wrote: On Friday, 4 September 2015 at 09:27:14 UTC, Benjamin Thaut wrote: On Friday, 4 September 2015 at 09:07:39 UTC, Szymon Gatner wrote: What about 32bit phobos? La

Re: Status of Win32 C++ interop

2015-09-04 Thread Benjamin Thaut via Digitalmars-d-learn
On Friday, 4 September 2015 at 10:04:48 UTC, Szymon Gatner wrote: On Friday, 4 September 2015 at 09:27:14 UTC, Benjamin Thaut wrote: On Friday, 4 September 2015 at 09:07:39 UTC, Szymon Gatner wrote: What about 32bit phobos? Last time I checked (2.067) only x64 was distributed. You have to c

Re: Status of Win32 C++ interop

2015-09-04 Thread Kagamin via Digitalmars-d-learn
See https://issues.dlang.org/show_bug.cgi?id=13889

Re: Status of Win32 C++ interop

2015-09-04 Thread Szymon Gatner via Digitalmars-d-learn
On Friday, 4 September 2015 at 09:27:14 UTC, Benjamin Thaut wrote: On Friday, 4 September 2015 at 09:07:39 UTC, Szymon Gatner wrote: What about 32bit phobos? Last time I checked (2.067) only x64 was distributed. You have to compile it yourself. Use the win64 makefile and replace the arch=64

Re: Status of Win32 C++ interop

2015-09-04 Thread Benjamin Thaut via Digitalmars-d-learn
On Friday, 4 September 2015 at 09:07:39 UTC, Szymon Gatner wrote: What about 32bit phobos? Last time I checked (2.067) only x64 was distributed. You have to compile it yourself. Use the win64 makefile and replace the arch=64 with arch=32mscoff. For more details see here: http://www.digital

Re: Status of Win32 C++ interop

2015-09-04 Thread Szymon Gatner via Digitalmars-d-learn
On Friday, 4 September 2015 at 08:58:41 UTC, Benjamin Thaut wrote: On Friday, 4 September 2015 at 08:53:27 UTC, Szymon Gatner wrote: Hi, what is the current status of: - Win x86/32bit/coff32 interop with C++? - improvements for general C++ interop that were suppose to come with 2.068 If

Re: Status of Win32 C++ interop

2015-09-04 Thread Benjamin Thaut via Digitalmars-d-learn
On Friday, 4 September 2015 at 08:53:27 UTC, Szymon Gatner wrote: Hi, what is the current status of: - Win x86/32bit/coff32 interop with C++? - improvements for general C++ interop that were suppose to come with 2.068 If you use either the -m64 or -mscoff32 interop should be pretty good

Status of Win32 C++ interop

2015-09-04 Thread Szymon Gatner via Digitalmars-d-learn
Hi, what is the current status of: - Win x86/32bit/coff32 interop with C++? - improvements for general C++ interop that were suppose to come with 2.068

documentation for C/C++ interop

2015-08-27 Thread Laeeth Isharc via Digitalmars-d-learn
would someone care to work on updating this? I understand from Daniel's post in main list that the only thing that doesn't work is special member functions. that's different from what the documents say, and it is surely something important for D that people are aware of this. I don't really

Re: C# interop

2011-01-30 Thread Eelco Hoogendoorn
Given that I explicitly stated my interest in to the metal programming, I dont think the .NET implementation will do me any good, no matter how perfectly implemented it is.

Re: C# interop

2011-01-30 Thread Trass3r
As Simen said, there was an attempt to create an IL backend but it hasn't been updated since Aug 2009 and even it compiled you probably wouldn't have much fun with it. You could try to use a C bridge. But even then, I don't see the benefit.

Re: C# interop

2011-01-30 Thread Simen kjaeraas
Eelco Hoogendoorn wrote: Hi, I am trying to combine C# and D, to get what is to me the best of both worlds; large libraries and excellent toolchain, with to the metal programming. Currently, I am doing this by means of C#/CLI/C++ interop, but I got reminded as to why I hate C++ so much

C# interop

2011-01-30 Thread Eelco Hoogendoorn
Hi, I am trying to combine C# and D, to get what is to me the best of both worlds; large libraries and excellent toolchain, with to the metal programming. Currently, I am doing this by means of C#/CLI/C++ interop, but I got reminded as to why I hate C++ so much after spending a few days trying