The following does not work, but how should I be able to get it to work?
#!/usr/bin/env -S nim r
#
# File: test1.nim
import strutils
proc getSomething() : ptr {.importc.}
proc setSomething(pvalue: ptr) {.importc.}
{. emit: """
static void *Something;
void *`getSomething`()
{
return Something;
}
void `setSomething`(void *thing)
{
Something = thing;
}
""" .}
const str:cstring = "This is a test string"
echo "starting: $1\n" % $str
setSomething(cast[ptr](str))
let back = getSomething()
echo "Getting back: $1\n" $ $(back[])
With thanks.