File: function6c.c

package info (click to toggle)
chibicc 1.0.23.2-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 5,832 kB
  • sloc: ansic: 62,911; sh: 275; makefile: 92
file content (30 lines) | stat: -rw-r--r-- 600 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#include <stdio.h>
#include <stdarg.h>
#include "test.h"

void test_variadic(double first_named, int count, ...) {
    printf("named arg = %f\n", first_named);

    va_list ap;
    va_start(ap, count);

    for (int i = 0; i < count; i++) {
        double val = va_arg(ap, double);
        printf("variadic arg[%d] = %f\n", i, val);
        if (i == 15)
            ASSERT(15, val );
    }

    va_end(ap);
}

int main() {
    test_variadic(
        0.0, 15,
        1.1, 2.2, 3.3, 4.4,
        5.5, 6.6, 7.7, 8.8,
        9.9, 10.10, 11.11, 12.12,
        13.13, 14.14, 15.15
    );
    return 0;
}