say you have a C function:
void store(void* data);
then you can using Nim ffi like this:
proc store(data: pointer) {.importc, dynlib: "shared lib name".}
or pretend that the argument is a cstring
proc store(data: cstring) {.importc, dynlib: "shared lib name".}
how to use the first one?
var mydata = "something"
store(mydata[0].addr) #get the underlying char* address
#or
store(mydata.cstring) # implicit cast from char* to void*
#or
store(cast[pointer](mydata.cstring)) #unnecessary, but ok too
how to use the second one?
var mydata = "something"
store(mydata) #use Nim's automatic conversion from string to cstring
#or
store(mydata.cstring) #unnecessary, but it's ok too.