Search code examples
dtangophobos

DMD Phobos-to-Tango conversion: va_arg - what is it? and what do I replace it with?


I'm trying to convert some Phobos code to its Tango equivalent, but I am stuck on this piece of code that I don't completely understand:

OutBuffer codebuf;

(...)

void gen(Loc loc, uint opcode, uint argc, ...)
{
    codebuf.reserve((1 + argc) * uint.sizeof);
    codebuf.write(combine(loc, opcode));
    for (uint i = 1; i <= argc; i++)
    {
        codebuf.write(va_arg!(uint)(_argptr));
    }
}

It's va_arg in particular that causes the error:

dmdscript_tango\irstate.d(215): Error: undefined identifier va_arg
dmdscript_tango\irstate.d(215): Error: function expected before (), not va_arg of type int

Is anyone able to share some insights into how to get around this problem? :-)


Solution

  • You don't need to replace it at all. Just import tango.core.Vararg;

    Or, if that doesn't work, try tango.stdc.stdarg;

    See also the according documentation at http://dsource.org/projects/tango/docs/current/tango.stdc.stdarg.html