From 90bf56f456e22dcd98458eca14e0b152a5efb179 Mon Sep 17 00:00:00 2001 From: _ov4 Date: Thu, 22 Oct 2026 13:30:00 +0000 Subject: 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 --- tests/i/extern-c-struct/lib.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'tests/i/extern-c-struct/lib.c') 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 + 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; +} -- cgit v1.3.1-4-g156e