diff options
| author | 2025-11-23 15:26:55 +0100 | |
|---|---|---|
| committer | 2025-11-23 15:33:38 +0100 | |
| commit | a9e0174fb69f3ddc85cd9c510b68cec22b6ebf42 (patch) | |
| tree | c633c8c514bdcc8b729050685adef3e1c4b826f2 /test | |
| parent | 1f72464c6451fcff16180d00af537225acc9b83c (diff) | |
c: __builtin_va_copy
Diffstat (limited to 'test')
| -rw-r--r-- | test/10-varargs.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/test/10-varargs.c b/test/10-varargs.c index a3715ab..a523d97 100644 --- a/test/10-varargs.c +++ b/test/10-varargs.c @@ -2,6 +2,8 @@ 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 = 36 <1.5> 1.1 + 2.1 + 3.1 + 5.1 + 1.5 + -1.5 + 1.5 + -1.5 + 1.5 + -1 = 11.9 +fwd()/1: Hello World +fwd()/2: Hello World */ @@ -37,9 +39,24 @@ double sumf(double x, ...) { return x; } +void fwd(const char *fmt, ...) { + va_list ap, aq; + va_start(ap, fmt); + va_copy(aq, ap); + printf("fwd()/1: "); + vprintf(fmt, ap); + va_end(ap); + printf("\n"); + printf("fwd()/2: "); + vprintf(fmt, aq); + printf("\n"); + va_end(aq); +} + int main() { printf(" = %d\n", sum(1,2,3,4,5,6,7,8,0,0)); printf("<%g>\n", stkarg(0,0,0,0,0,0,0,0,1.5)); printf(" = %g\n", sumf(1.1, 2.1, 3.1, 5.1, 1.5, -1.5, 1.5, -1.5, 1.5, -1.0, 0.0)); + fwd("%s %s", "Hello", "World"); } |