Using D libs in C
bearophile
bearophileHUGS at lycos.com
Sun Mar 27 03:41:34 PDT 2011
Dainius (GreatEmerald):
> OK, now I have a question about passing variables. In D, I have a
> dynamic array of strings and I want C to get that array. Yet C
> supports neither dynamic arrays nor strings. So is there a way to
> accomplish this?
To use a D data structure from C you need first of all to know what exactly those data structures are.
In this case one solution is to create (from D) a dynamic array of char*, then perform a map!toStringz to convert the strings to C strings, and then call the C code with the ptr and length of this dynamic array of pointers.
There are other solutions, according to the amount of data you want to copy or according to the amount of C code you want to write to access the D data structures.
Bye,
bearophile
More information about the Digitalmars-d-learn
mailing list