Thread overview | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
February 18, 2007 How to redirect variadic function parameters? | ||||
---|---|---|---|---|
| ||||
In case I have void foo(...) {} void bar(...) {} how should I call bar from foo and passing along all the parameters? void foo(...) { bar(?); } // bar(...) doesn't work thanks, Mikko |
February 19, 2007 Re: How to redirect variadic function parameters? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Mikko | Mikko wrote:
> In case I have
>
> void foo(...) {}
> void bar(...) {}
>
> how should I call bar from foo and passing along all the parameters?
>
> void foo(...) { bar(?); } // bar(...) doesn't work
>
> thanks, Mikko
You have to create a different, non-variadic function that takes _arguments and _argptr as arguments.
See for example writefx in phobos/std/stdio.d:
void writefx(FILE* fp,
TypeInfo[] arguments, void* argptr,
int newline=false);
Or use variadic templates, which can be passed from one function to another.
--bb
|
February 19, 2007 Re: How to redirect variadic function parameters? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Bill Baxter | Bill Baxter wrote: > You have to create a different, non-variadic function that takes _arguments and _argptr as arguments. > > See for example writefx in phobos/std/stdio.d: > void writefx(FILE* fp, > TypeInfo[] arguments, void* argptr, > int newline=false); The portable version uses "std.stdarg.va_list" instead: void writefx(FILE* fp, TypeInfo[] arguments, va_list argptr, int newline=false); Should be the same for DMD, but is a built-in for GDC. (need to use va_arg, instead of pointer manipulations) --anders http://www.prowiki.org/wiki4d/wiki.cgi?DocComments/Function#PortabilityandVariadicFunctions |
February 19, 2007 Re: How to redirect variadic function parameters? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Anders F Björklund | Anders F Björklund wrote:
> Bill Baxter wrote:
>
>> You have to create a different, non-variadic function that takes _arguments and _argptr as arguments.
>>
>> See for example writefx in phobos/std/stdio.d:
>> void writefx(FILE* fp,
>> TypeInfo[] arguments, void* argptr,
>> int newline=false);
>
> The portable version uses "std.stdarg.va_list" instead:
> void writefx(FILE* fp, TypeInfo[] arguments, va_list argptr, int newline=false);
>
> Should be the same for DMD, but is a built-in for GDC.
> (need to use va_arg, instead of pointer manipulations)
>
> --anders
>
> http://www.prowiki.org/wiki4d/wiki.cgi?DocComments/Function#PortabilityandVariadicFunctions
>
Is there any reason why bar(...) couldn't be implemented? It's a mich nicer syntax.
|
February 19, 2007 Re: How to redirect variadic function parameters? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Robin Allen | "Robin Allen" <r.a3@ntlworld.com> wrote in message news:erd25h$li1$2@digitalmars.com... > > Is there any reason why bar(...) couldn't be implemented? It's a mich nicer syntax. I think we had a topic on this not much more than a week ago, and came to much the same conclusion. |
August 02, 2007 Re: unbuffered dout | ||||
---|---|---|---|---|
| ||||
Posted in reply to Anders F Björklund | > --anders http://www.prowiki.org/wiki4d/wiki.cgi?DocComments/Function#PortabilityandVariadicFunctions Your link does not work. Software error: File-Open-Fehler (/usr/home/wikise/wiki/slurp/163.181.251.9.rl): Disc quota exceeded at /usr/local/etc/httpd/htdocs/prowiki/wiki.cgi line 5351. ----------- Anyway, I need to do this too, but my real question is: How do I turn off dout buffering? Otherwise, I need to redirect writefln(...) to fwritefln(derr,...). |
Copyright © 1999-2021 by the D Language Foundation