Note: This website is archived. For up-to-date information about D projects and development, please visit

Variable Arguments

Part of StandardLibraryCategory


Use std.c.stdarg for variable arguments.

The std.c.stdarg module is now obsolete with the release of DMD 0.93. Use std.stdarg instead (see VariableArgumentsUsingStdStdargExample).


import std.c.stdarg;

int foo(char *x, ...)
    va_list ap;

    va_start!(typeof(x))(ap, x);
    printf("&x = %p, ap = %p\n", &x, ap);

    int i;
    i = va_arg!(typeof(i))(ap);
    printf("i = %d\n", i);

    long l;
    l = va_arg!(typeof(l))(ap);
    printf("l = %lld\n", l);

    uint k;
    k = va_arg!(typeof(k))(ap);
    printf("k = %u\n", k);


    return i + l + k;

void main()
    int j;

    j = foo("hello", 3, 23L, 4);
    printf("j = %d\n", j);
    assert(j == 30);


Adapted from digitalmars.D/273.