Hello i have the following proc:
proc createConfig*(configName: cstring; returnedConfig: ptr ptr Config): ReturnedValue {.
cdecl, importc: "createConfig", dynlib: albinosdll.}
I'm trying to call the function without any success:
proc main =
config.loadConfig()
var cfg : Config
var cstr: cstring = "mycfg"
discard createConfig(cstr, cfg.addr)
main()
I'm new in nim i want to create a pointer directly and send the address if it's possible.
Ok this work like a charm with:
proc main =
config.loadConfig()
var cfg : Config
var cfgp = addr cfg
var cstr: cstring = "mycfg"
discard createConfig(cstr, cfgp.addr)
main()
There is a better way to write the equivalent ? a more idiomatic one ?
Is config.loadConfig() used for something in your snippet?
You can either do cfg.addr.addr or do var cfg: ptr ptr Config, you can choose between more or less ptr vs addr.