Thread overview | |||||
---|---|---|---|---|---|
|
April 02, 2005 How to convert va_start macro to D function? | ||||
---|---|---|---|---|
| ||||
How can I convert this to D? #define va_start(ap,v) ( ap = (va_list)_ADDRESSOF(v) + _INTSIZEOF(v) ) |
April 02, 2005 Re: How to convert va_start macro to D function? | ||||
---|---|---|---|---|
| ||||
Posted in reply to V | On Fri, 01 Apr 2005 20:39:24 -0800, V wrote: > How can I convert this to D? > > #define va_start(ap,v) ( ap = (va_list)_ADDRESSOF(v) + _INTSIZEOF(v) ) Generally speaking, you don't. You use the template va_arg which is found in the std.stdarg.d module. <code> /* * Placed in public domain. * Written by Hauke Duden and Walter Bright */ /* This is for use with variable argument lists with extern(D) linkage. */ module std.stdarg; alias void* va_list; template va_arg(T) { T va_arg(inout va_list _argptr) { T arg = *cast(T*)_argptr; _argptr = _argptr + ((T.sizeof + int.sizeof - 1) & ~(int.sizeof - 1)); return arg; } } </code> -- Derek Parnell Melbourne, Australia 2/04/2005 4:58:48 PM |
April 02, 2005 Re: How to convert va_start macro to D function? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Derek Parnell | Thanks Derek, I found va_start defined in std.c.stdarg
I hadn't seen it on the website but from now on, I'll just look in the actual src folders. :D
V
Derek Parnell wrote:
> On Fri, 01 Apr 2005 20:39:24 -0800, V wrote:
>
>
>>How can I convert this to D?
>>
>>#define va_start(ap,v) ( ap = (va_list)_ADDRESSOF(v) + _INTSIZEOF(v) )
>
>
> Generally speaking, you don't. You use the template va_arg which is found
> in the std.stdarg.d module.
>
> <code>
> /*
> * Placed in public domain.
> * Written by Hauke Duden and Walter Bright
> */
>
> /* This is for use with variable argument lists with extern(D) linkage. */
>
> module std.stdarg;
>
> alias void* va_list;
>
> template va_arg(T)
> {
> T va_arg(inout va_list _argptr)
> {
> T arg = *cast(T*)_argptr;
> _argptr = _argptr + ((T.sizeof + int.sizeof - 1) & ~(int.sizeof - 1));
> return arg;
> }
> }
>
> </code>
>
|
Copyright © 1999-2021 by the D Language Foundation