Closed deepankarsharma closed 2 months ago
When a C-level result is a struct, then the procedure created by foreign-procedure
needs a pointer to copy the result struct into. The pointer is provided to fp
as an extra argument before all of the others. This is described in the documentation at the second (& ftype-name):
, which is in the part about result types.
So, the intended calling pattern is like this:
> (define c (make-color 4 4 4 4))
> (define result (make-color 0 0 0 0))
> (fp result c 44.) ; `result` content is modified to be the return value
Thank you for the clarification!
Closing since this was not a bug but an oversight on my part.
I am wrapping this C api
in the following way
Based on my reading of (&) can be used to send and receive structs by value.
However when trying to use the above code I get an arity-error. For some reason Chez thinks that this is a function that takes three arguments.
Calling it with three arguments appears to not throw any errors.