开发者

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: undefine开发者_如何转开发d 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? :-)


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


check out http://d-programming-language.org/phobos/core_vararg.html

void gen(Loc loc, uint opcode, uint argc,...)
{
    codebuf.reserve((1 + argc) * uint.sizeof);
    codebuf.write(combine(loc, opcode));

    va_list v_arg;
    va_start(v_arg,argc);
    scope(exit)va_end(v_arg); 

    for (uint i = 1; i <= argc; i++)
    {
        codebuf.write(va_arg!(uint)(v_arg));
    }
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜