|
Archives
D Programming
DD.gnu digitalmars.D digitalmars.D.bugs digitalmars.D.dtl digitalmars.D.dwt digitalmars.D.announce digitalmars.D.learn digitalmars.D.debugger C/C++ Programming
c++c++.announce c++.atl c++.beta c++.chat c++.command-line c++.dos c++.dos.16-bits c++.dos.32-bits c++.idde c++.mfc c++.rtl c++.stl c++.stl.hp c++.stl.port c++.stl.sgi c++.stlsoft c++.windows c++.windows.16-bits c++.windows.32-bits c++.wxwindows digitalmars.empire digitalmars.DMDScript |
D - stdarg.h macro translation assistance
The following macros are defined in stdarg.h (DM):
[QUOTE]
typedef char __SS *va_list;
#define va_start(ap,parmn) ((void)((ap) =
(va_list)&(parmn)+__va_size(parmn)))
#define va_arg(ap,type) (*(type __SS
*)(((ap)+=__va_size(type))-(__va_size(type))))
#define va_end(ap) ((void)0)
[/QUOTE]
va_list is included in std.c.stdio but the rest are not.
I was wondering if someone would assist in the proper prototype of these
macros.
Here is what I came up with:
void va_start(va_list ap, void[] param)
{
ap = (cast(va_list)¶m+param.size;
}
va_arg // not sure what to make of this one
void va_end(va_list ap)
{
ap = null;
}
I use them in a program that compiles and links correctly but does not works
as expected.
Not sure if it's because I'm missing va_arg or because I messed up defining
the other two.
Any help is appreciated,
Andrew
Apr 22 2004
Unfortuately, there's no way to do them in D. When I do it, I just code them explicitly. Apr 23 2004
In article <c6ajvr$2n6p$1 digitaldaemon.com>, Walter says...Unfortuately, there's no way to do them in D. When I do it, I just code them explicitly. Apr 23 2004
When I say it won't work in D, perhaps I was misleading. You certainly can access variadic parameters in D exactly as you'd do in C, the problem is you cannot create a *macro* to do it for you. If you write the macro expansions in D, it will work fine. I haven't expended much effort in this direction, because variadic argument lists are rarely used (typically only for printf and scanf). Apr 23 2004
|