karantin2020
4/12/2016 - 8:19 PM

wrap.nim

const path = "./"

{.passc: "-I" & path.}
{.compile: path & "main.c"}


type
    df {.pure, final, importc: "def_t", header: "./head.h".} = object
        fn: proc (s: cstring) {.cdecl.}

var
    def {.importc: "def", header: "./head.h".}: df

proc start() {.cdecl, importc: "start", header: "./head.h".}

proc foo(s: cstring) {.cdecl.} = 
    write stdout, s

def.fn = foo

start()
echo "repr"
echo repr def