Wrapping c variadic functions

simendsjo simendsjo at gmail.com
Thu Feb 23 03:07:21 PST 2012


On Thu, 23 Feb 2012 11:35:32 +0100, simendsjo <simendsjo at gmail.com> wrote:

> Say i have a c function (didn't include first format argument for  
> simplicity)
>
> void print(...);
> I wrap it up:
> extern(System) void print(...);
>
> And then I try to wrap it up in some safer D way:
> void print(Args...)(Args args)
> {
>      print(args); // only the first argument is printed
> }
>
> void print(...)
> {
>      print(_argptr); // no go either
> }
>
> How am I supposed to do this? http://dlang.org/function.html#variadic  
> doesn't make my any smarter.

My bad. The first version works just fine. I passed a float and had the  
format string as %d...


More information about the Digitalmars-d-learn mailing list