Thanks for that suggestion; I've made some progress. You were right to wonder whether it was related to passing parameters by value. It turns out that proc fprint*(value: value_t; stream: File): clonglong {.cdecl, importc: "neo4j_fprint", dynlib: libneo4j.}
gets converted to typedef N_CDECL_PTR(long long, TY_cCLPRp1DVAZDRduZNEg73g) (value_t_0EYYJ3aKtwLRJQYI9cfqKlA* value, FILE* stream); For some reason, what should be passed by value instead gets passed by reference, which of course confuses the actual C implementation. When I manually edited the C output to fix this, everything worked as expected. Any idea how I can make Nim compile my code correctly? Or is this a compiler bug?