Skip to content
IsaacShelton edited this page Mar 21, 2022 · 1 revision

va_arg

va_arg is used to extract a value from a va_list

va_arg(my_va_list, Type)

Supported Types

Since va_arg is for C style variadic arguments, non-primitive types are not supported

Usage Example

import basics

func main {
    print(sizeof va_list)
    print(addEmUp(4, 10si, 11si, 12si, 13si))
}

func addEmUp(count usize, ...) int {
    ap, ap2 va_list
    sum int

    va_start ap
    defer va_end ap

    va_copy(ap2, ap)

    repeat count {
        sum += va_arg(ap, int)
        sum += va_arg(ap2, int)
    }

    return sum
}
Clone this wiki locally