view test/vararg1.d @ 133:44a95ac7368a trunk

[svn r137] Many fixes towards tango.io.Console working, but not quite there yet... In particular, assertions has been fixed to include file/line info, and much more!
author lindquist
date Mon, 14 Jan 2008 05:11:54 +0100
parents 3a784f7790d6
children d9d5d59873d8
line wrap: on
line source

module vararg1;

import std.c.stdarg;

extern(C) int add(int n, ...)
{
    va_list ap=void;
    va_start(ap, n);
    int r;
    for (int i=0; i<n; i++)
        r += va_arg!(int)(ap);
    va_end(ap);
    return r;
}

void main()
{
    int i = add(4,1,2,3,4);
    assert(i == 10);
}