proc ask(question: cstring) {.exportc.}
And calling it like this from C:
void ask(char* string);
...
ask("How do you do?");
I get a runtime panic telling me memory is freed twice. The problem goes away if I give the proc a malloc'ed string and leave ownership to Nimrod.
Is there a praga to let Nimrod know I shall take full ownership of my strings?
(BTW, just discovered Nimrod. It seems to be completely awesome, thanks!)
[Using 0.9.2 on OS X installed with Homebrew]
Caveat: I have worked with Nimrod a full 20 minutes and might have missed something obvious.
Welcome!
Your snippets are not enough to tell you where the problem is. cstring in general are not GC'ed at all, so your snippets should work, unless you do something wrong in ask. ;-)
Hm, I went to replicate the error to provide more detail, but was unable to. Only problem I have now is I don't know what fixed it.
Anyway, it helps to know that cstrings are supposed to work the way they ought to. Thanks!