Re: interfacing c++

2017-11-22 Thread drug via Digitalmars-d-learn
22.11.2017 19:06, Markus пишет: another indicator (as documented) that GC destructor won't work // extern(C++) classes don't have a classinfo pointer in their vtable so the GC can't finalize them https://github.com/dlang/druntime/blob/3d8d4a45c01832fb657c16a656b6e1566d77fb21/src/rt/lifetime.d#L9

Re: interfacing c++

2017-11-22 Thread Markus via Digitalmars-d-learn
another indicator (as documented) that GC destructor won't work // extern(C++) classes don't have a classinfo pointer in their vtable so the GC can't finalize them https://github.com/dlang/druntime/blob/3d8d4a45c01832fb657c16a656b6e1566d77fb21/src/rt/lifetime.d#L90 annoying :( Markus

Re: interfacing c++

2017-11-22 Thread Markus via Digitalmars-d-learn
On Wednesday, 22 November 2017 at 08:43:54 UTC, drug wrote: 22.11.2017 02:12, Markus пишет: What about dtor - you allocate class using D GC but try to destroy it manually - namely this I guess gives you an error in rt_finalize2 because it tries to destroy object that has been destroyed. hmm...

Re: interfacing c++

2017-11-22 Thread drug via Digitalmars-d-learn
22.11.2017 02:12, Markus пишет: snip I could do the instancing/destruction by functions and write a custom d class that calls these methods in this()/~this(). This is what I used to do as special members like ctor/dtor did not supported in D before, but your example of using ctor is interesti

Re: interfacing c++

2017-11-22 Thread MGW via Digitalmars-d-learn
On Wednesday, 22 November 2017 at 08:29:26 UTC, MGW wrote: Possibly it will be interesting https://pp.userapi.com/c639524/v639524332/60240/uH3jnxrchik.jpg

Re: interfacing c++

2017-11-22 Thread MGW via Digitalmars-d-learn
On Tuesday, 21 November 2017 at 23:12:33 UTC, Markus wrote: hi, im trying to interface a cpp class. I'd like to interface a bigger library and I'm trying to figure out the minimum effort. Possibly it will be interesting https://www.youtube.com/watch?v=HTgJaRRfLPk

Re: Interfacing C++ to D

2017-04-03 Thread ANtlord via Digitalmars-d-learn
On Sunday, 2 April 2017 at 16:03:51 UTC, FreeSlave wrote: Funny thing: If I replace interface with abstract class, it works as it should. Also I noticed that removing inheritance in library and in application makes unexpected results. When I try to output field `field` I get incorrect rando

Re: Interfacing C++ to D

2017-04-02 Thread FreeSlave via Digitalmars-d-learn
On Sunday, 2 April 2017 at 16:03:51 UTC, FreeSlave wrote: On Sunday, 2 April 2017 at 16:02:06 UTC, FreeSlave wrote: On Sunday, 2 April 2017 at 09:58:19 UTC, ANtlord wrote: [...] Now I see. 'Using C++ Classes From D' crashes for me too. It also returns the wrong value from 'field' method. Sho

Re: Interfacing C++ to D

2017-04-02 Thread FreeSlave via Digitalmars-d-learn
On Sunday, 2 April 2017 at 16:02:06 UTC, FreeSlave wrote: On Sunday, 2 April 2017 at 09:58:19 UTC, ANtlord wrote: On Saturday, 1 April 2017 at 16:39:28 UTC, FreeSlave wrote: This page has many examples. Which exactly do you try to run and how do you build it? Which compilers, OS? My bad. I've

Re: Interfacing C++ to D

2017-04-02 Thread FreeSlave via Digitalmars-d-learn
On Sunday, 2 April 2017 at 09:58:19 UTC, ANtlord wrote: On Saturday, 1 April 2017 at 16:39:28 UTC, FreeSlave wrote: This page has many examples. Which exactly do you try to run and how do you build it? Which compilers, OS? My bad. I've tested example under caption Using C++ Classes From D. I

Re: Interfacing C++ to D

2017-04-02 Thread ANtlord via Digitalmars-d-learn
On Sunday, 2 April 2017 at 09:58:19 UTC, ANtlord wrote: On Saturday, 1 April 2017 at 16:39:28 UTC, FreeSlave wrote: This page has many examples. Which exactly do you try to run and how do you build it? Which compilers, OS? My bad. I've tested example under caption Using C++ Classes From D. I

Re: Interfacing C++ to D

2017-04-02 Thread ANtlord via Digitalmars-d-learn
On Saturday, 1 April 2017 at 16:39:28 UTC, FreeSlave wrote: This page has many examples. Which exactly do you try to run and how do you build it? Which compilers, OS? My bad. I've tested example under caption Using C++ Classes From D. I used several combinations of compilers, and no one works

Re: Interfacing C++ to D

2017-04-01 Thread FreeSlave via Digitalmars-d-learn
On Saturday, 1 April 2017 at 07:37:25 UTC, ANtlord wrote: Hello! Can somebody give a relevant example shows how to use C++ classes in D? I've used the exmaple from https://dlang.org/spec/cpp_interface.html but I get a segmentation fault as result of D application. My application shows "Progr

Re: Interfacing C++ to D --> or better: C++ --> C ---> D (DLL)

2014-03-30 Thread evilrat
On Sunday, 30 March 2014 at 11:16:16 UTC, BeschBesch wrote: have you looked at exported symbols in dll? it may be C++ from what you said(lib not designed for C++?), so you can try extern(C++) on D side instead extern(C). or add manually #ifdef __cplusplus and extern "C" on lib side(if its not t

Re: Interfacing C++ to D --> or better: C++ --> C ---> D (DLL)

2014-03-30 Thread BeschBesch
have you looked at exported symbols in dll? it may be C++ from what you said(lib not designed for C++?), so you can try extern(C++) on D side instead extern(C). or add manually #ifdef __cplusplus and extern "C" on lib side(if its not that big of course). First of all: I started with a C++-dll

Re: Interfacing C++ to D --> or better: C++ --> C ---> D (DLL)

2014-03-30 Thread evilrat
On Saturday, 29 March 2014 at 15:03:18 UTC, BeschBesch wrote: I want to use a set of functions that rely on a library which is not available for D (Harfbuzz). So I just wrote myself a set a functions that will do anything I need (Init, Free, Fonts, Text, etc). The DLL is working fine and dyna

Re: Interfacing C++ to D --> or better: C++ --> C ---> D (DLL)

2014-03-29 Thread BeschBesch
extern (C) /// needed so the compiler can link the functions { void Test(); } The function of course is called "Test1" not Test.

Re: Interfacing C programs: Pass D string to C function

2013-12-14 Thread Jonathan M Davis
On Friday, December 13, 2013 01:17:41 Jonathan M Davis wrote: > or you could do something like > > auto cstr = str.dup.ptr; Wait. That was stupid of me. Don't do this. It'll give you a char*, but it won't be null-terminated. If you need char*, then use toUTFz!(char*) - though from what Mike's s

Re: Interfacing C programs: Pass D string to C function

2013-12-13 Thread Mike Parker
On 12/13/2013 5:00 PM, Dfr wrote: Hello I trying to write simple wrapper around pcre and have problem passing strings to it. As i understood, the best way is std.string.toStringZ. So, my code look like: string pattern = ""; pcre_compile2( toStringz(pattern), options, &errcode, &errmsg, &er

Re: Interfacing C programs: Pass D string to C function

2013-12-13 Thread Jonathan M Davis
On Friday, December 13, 2013 09:00:20 Dfr wrote: > Hello > > I trying to write simple wrapper around pcre and have problem > passing strings to it. As i understood, the best way is > std.string.toStringZ. > > So, my code look like: > > string pattern = ""; > pcre_compile2( toStringz(pattern)

Re: Interfacing C programs: Pass D string to C function

2013-12-13 Thread Ithy
On Friday, 13 December 2013 at 08:00:21 UTC, Dfr wrote: Hello I trying to write simple wrapper around pcre and have problem passing strings to it. As i understood, the best way is std.string.toStringZ. So, my code look like: string pattern = ""; pcre_compile2( toStringz(pattern), optio