Hello again,
I'm trying to wrap a c++ library, the function I want to call has the following
prototype:
`void UnpackGWDat( unsigned char *input, int insize, unsigned char *&output,
int &outsize )`
I tried the following wrapper:
proc unpackWrapper(input: cstring, inputSize: cint, output {.byref.}:
cstring, outputSize {.byref.}: cint) {.importcpp: "UnpackGWDat(@)".}
import sequtils
proc uncompress*(compressed: openArray[byte], compressedSize: int): cstring
=
var input: string
input.setLen(compressedSize)
for i in 0..<compressedSize:
input[i] = cast[char](compressed[i])
var
uncompressedFile: cstring
uncompressedSize: cint
unpackWrapper(input, cast[cint](compressedSize), uncompressedFile,
uncompressedSize)
return uncompressedFile
Run
I get the following error:
`.cache/nim/dat_d/@mhuffman.nim.cpp:967:75: error: cannot bind rvalue
‘(unsigned char*)uncompressedFile’ to ‘unsigned char*&’ 967 |
UnpackGWDat(nimToCStringConv(input), ((int) (compressedSize_p1)),
uncompressedFile, uncompressedSize);`
What would be the correct way to do this?