on interfacing w/C++

Moritz Maxeiner via Digitalmars-d digitalmars-d at puremagic.com
Wed Apr 16 07:57:45 PDT 2014


On Wednesday, 16 April 2014 at 14:00:24 UTC, Daniel Murphy wrote:
> "Moritz Maxeiner"  wrote in message 
> news:kvzwlecwougswrqkatcs at forum.dlang.org...
>
>> Is this[1] then out of date and I can interface with 
>> non-virtual methods? Because that's what your post seems to 
>> imply (unless I misunderstood).
>>
>> [1] http://dlang.org/cpp_interface.html
>
> Yes.  The best place to look for concrete examples of what is 
> supported is probably the C++ tests in the test suite.  (ie 
> files containing "EXTRA_CPP_SOURCES")

That sounds very cool, I've had a look at [1] and [2], which seem 
to be the two files with the new C++ class interfacing. As far as 
I could tell, you need to create any instances of C++ classes 
with C++ code / you don't bind to the constructors directly from 
D and the new instance will not be managed by D's GC? Because if 
I used this new interfacing for e.g. llvm-d, I need to be sure, 
that D's GC won't touch any of the instances under any 
circumstances, since they are freed by LLVM's internal logic they 
GC cannot track.

[1] 
https://github.com/D-Programming-Language/dmd/blob/master/test/runnable/externmangle.d
[2] 
https://github.com/D-Programming-Language/dmd/blob/master/test/runnable/extra-files/externmangle.cpp


More information about the Digitalmars-d mailing list