Skip to content

va_start

IsaacShelton edited this page Mar 21, 2022 · 1 revision

va_start

va_start is used to initialize a va_list

va_start my_va_list

or

va_start(my_va_list)

Usage Example

import basics

func main {
    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