diff options
| author | _ov4 <ov4@ov4.org> | 2026-10-22 13:30:00 +0000 |
|---|---|---|
| committer | _ov4 <ov4@ov4.org> | 2026-10-22 13:30:00 +0000 |
| commit | 90bf56f456e22dcd98458eca14e0b152a5efb179 (patch) | |
| tree | 629f46a15ea13d1d71998355f00d77d5c80052a3 /tests/i/extern-c-struct/lib.c | |
| parent | 4a70e44f06e637762eec0fd875eb94b84c3f4037 (diff) | |
feat(codegen): accept record pointers as variadic arguments
Pointer types to C-struct records now pass unchanged as variadic EXTERN
arguments. Pseudocode values still need a cast to a C type, and records
by value stay rejected.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'tests/i/extern-c-struct/lib.c')
| -rw-r--r-- | tests/i/extern-c-struct/lib.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/tests/i/extern-c-struct/lib.c b/tests/i/extern-c-struct/lib.c index 39380ec..65080f1 100644 --- a/tests/i/extern-c-struct/lib.c +++ b/tests/i/extern-c-struct/lib.c @@ -1,3 +1,5 @@ +#include <stdarg.h> + struct Sample { char tag; double value; @@ -9,3 +11,13 @@ static struct Sample shared = {'G', 0.5, 7}; void scale_sample(struct Sample *s, int k) { s->value *= k; } struct Sample *shared_sample(void) { return &shared; } int shared_count(void) { return shared.count; } + +/* Each argument after n is a struct Sample *, read back with va_arg. */ +int sum_counts(int n, ...) { + va_list ap; + int total = 0; + va_start(ap, n); + for (int i = 0; i < n; ++i) total += va_arg(ap, struct Sample *)->count; + va_end(ap); + return total; +} |
