Swig: passing unsigned char array from C++ to Java -


i have c++ function in .cpp file; unsigned char *myfunc(). how can convert array in byte[] array in java? mean, in java, want like:

byte[] b = mylib.myfunc();

i using swig , appearently need define kind of conversion unsigned char byte in .i file, don't know how.

thank in advance

try returning std::string instead of unsigned char* , %include <std_string.i> in .i file. std_string.i typemaps, might end byte[] on receiving side. if can change return type of myfunc create wrapper via %inline,

%inline %{     std::string myfuncstr() { return myfunc(); } %} 

if want can %rename myfuncstr myfunc, hiding fact myfunc exported java wrapper real myfunc.

if doesn't work, flexo's solution swig: convert return type std::string(binary) java byte[] will.


Comments

Popular posts from this blog

windows - Single EXE to Install Python Standalone Executable for Easy Distribution -

c# - Access objects in UserControl from MainWindow in WPF -

javascript - How to name a jQuery function to make a browser's back button work? -