idiom for C error strings

Daniel Kozák via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Tue Jul 21 05:40:37 PDT 2015


On Tue, 21 Jul 2015 12:27:55 +0000
"yawniek" <dlang at srtnwz.com> wrote:

> whats the proper way to use/wrap C functions  that expect a error 
> string buffer
> e.g.:
> somefun(T param1, char* errstr, size_t errstr_size)
>   in D ?
> 

dynamic:

auto buf = new char[size];
somefun(param1, buf.ptr, buf.length);
or
somefun(param1, buf.ptr, size);

static:

char[size] buf;
somefun(param1, &buf, size);




More information about the Digitalmars-d-learn mailing list