Hello,
I've been using Nim for a little while but until now I never dig in that space
of C API, at least not enough to encounter C callbacks. I want a simple thing,
pass a function pointer to C code and get the C code call my proc later on.
Luckily enough, the C API provides a userdata pointer to play with.
I believe there is a way Nim can do that. In Nim, a {.closure.} is represented
as a function pointer plus an environment pointer. This is exactly what the C
interface provides: a function pointer and a userdata. However how do I pass
those to the C api and how do I ensure that the C API provides the environment
pointer in the correct order with the other callback arguments? How do I ensure
that there will not be a garbage collector problem (using orc)?
Surprisingly I did not find very helpful occurrences of this problem when
searchin for more info.
The C API is sqlite: <https://www.sqlite.org/c3ref/set_authorizer.html>
bonus question: is there a way to do that if the C api does not provides a
userdata pointer?