#construct a va_list and pass it to a c function

1 messages · Page 1 of 1 (latest)

near oyster
#

i would like to do something like (from zig) c.vprintf(fmt, va_list) how can i construct a valid va list in zig?

#

how can i construct an instance of this struct?

finite nest
#

You are not meant to create it from scratch

#

but get it from a function

#
    pub fn someFunction(fmt: [*:0]u8, ...) callconv(.C) void {
        var vaList = @cVaStart();
        var copy = @cVaCopy(&vaList);
        std.c.vprintf(fmt, copy);
        @cVaEnd(&vaList);
}

Dunno if the copy is needed

#

buuut

#

yea

#

note this uses a variadic function definition, and that is only valid iirc from a C calling convention function

near oyster
finite nest
#

why would you need this

tawny palm
#

dynamically constructing a va_list just isn't really a directly supported use case afaik

#

how you would do it entirely depends on the particular C ABI