2015-06-20 70 views
2

这是我的目录结构:FFI和头文件

C:. 
│ lodepng.h 
│ lodepng.c 
│ nim.cfg 
│ test.png 
│ util.nim 
│ 
└───nimcache 

UTIL NIM从lodepng.h进口交流功能是这样的:

proc loadPNG(image: var ptr[cchar], width, height: var cuint, filename: cstring) 
    {.importc: "lodepng_decode32_file", header: "lodepng.h".} 

但头没有被复制到nimcache也不是编译代码时发现。我如何确保nim编译器使用它?

回答

1

我发现NIM backend integration guide内的解决方案:

{.compile: "lodepng.c".} 
proc lodepng_decode32_file(image: var ptr[cchar], width, height: var cuint, filename: cstring): cuint {.importc.}