How to use C code in D

Jesse Phillips via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Fri Mar 24 08:30:05 PDT 2017


On Thursday, 23 March 2017 at 18:10:20 UTC, Dillen Meijboom wrote:
> Hi there,
>
> I'm learning D for a while because it's really easy to use 
> C-code in D.
> The problem is that I don't really get how to deal with the 
> data structures defined in C in D.

D makes it easy to utilize C code, but there is no magic C to D 
wrapper. There are some functions in Phobos which help (e.g. 
toStringz). You can slice a C string to utilize it as a slice, 
but usually there are ownership issue with this approach. In my 
experience, you'll be writing some C style code to provide a D 
interface.


More information about the Digitalmars-d-learn mailing list