[gambit-list] Out parameters in the C FFI
Lassi Kortela
lassi at lassi.io
Wed Oct 2 07:42:32 EDT 2019
(Sorry if this basic question has been answered before; didn't find in
the list archives, wiki or manual.)
What's the general approach for wrapping C functions like this:
int foo(struct bar **out);
So the foo function sets *out to some value of type "struct bar *", and
we want to keep that "struct bar *" in Scheme and pass it around to
other FFI functions.
If it's not necessary to preserve the "int" return value then this can
be worked around by writing a wrapper function in C:
struct bar *my_foo_wrapper(void) {
struct bar *bar;
foo(&bar);
return bar;
}
But is there a more general way to get values from out parameters into
Scheme?
More information about the Gambit-list
mailing list