I am having an issue with the calling convention. I have the following function:
type
Consumer* = mlt_consumer
...
proc mlt_consumer_close*(a1: mlt_consumer) {.importc, cdecl, impmltDyn.}
...
proc close*(a:Consumer) =
mlt_consumer_close(a)
The following works:
close(c)
but not the following:
c.close()
giving me the following error:
Error: type mismatch: got <>
but expected one of:
proc (a1: mlt_consumer){.cdecl.}
Why am I having this issue?
Might be that impmltDyn macro is causing the a parameter to mlt_consumer_close to disappear. Try doing
import std/macros
expandMacros:
proc mlt_consumer_close*(a1: mlt_consumer) {.importc, cdecl, impmltDyn.}
and see what it expands to.If I've found the right code you've got
type ConsumerS = object
...
close: proc (a1: Consumer) {.cdecl.}
Consumer = ptr ConsumerS
which means c.close() refers to the member close of c, i.e. a proc which expects a parameter