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

Interfacing C programs: Pass D string to C function

2013-12-13 Thread Dfr
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); T