Use another language to call a function: Difference between revisions

Content deleted Content added
Line 594: Line 594:
<lang nimrod>proc Query*(data: var array[1024, char], length: var cint): cint {.exportc.} =
<lang nimrod>proc Query*(data: var array[1024, char], length: var cint): cint {.exportc.} =
const text = "Here am I"
const text = "Here am I"
if length > text.len:
if length < text.len:
for i in 0 .. <text.len:
return 0

data[i] = text[i]
length = text.len
for i in 0 .. <text.len:
return 1
data[i] = text[i]
length = text.len
return 0</lang>
return 1</lang>
Compile with <code>nimrod c --app:staticlib --no_main query.nim</code>
Compile with <code>nimrod c --app:staticlib --no_main query.nim</code>
<lang c>#include <stdio.h>
<lang c>#include <stdio.h>