Interfacing C programs: Pass D string to C function

Ithy n at n.n
Fri Dec 13 00:17:20 PST 2013


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), options, &errcode, &errmsg, 
> &erroffset, cast(char*)null);
>
> This gives me error:
>
> Error: function pcre_compile2 (char*, int, int*, char**, int*, 
> char*) is not callable using argument types (immutable(char)*, 
> int, int*, char**, int*, char*)
>
> Any ideas for better way to do this task ?

Try using cast(char*)pattern


More information about the Digitalmars-d-learn mailing list