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 |
if length < text.len: |
||
return 0 |
|||
data[i] = text[i] |
|||
for i in 0 .. <text.len: |
|||
data[i] = text[i] |
|||
length = text.len |
|||
return |
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> |