سؤال

I'm using the SWIG library to let a Java (Android) app call C functions.

I need to have some of my C functions return variable-sized arrays back to Java. How can I do this?

I've considered converting a long long * to a jlongarray, but I don't know how to pass the jlongarray back to Java with SWIG.

Does anyone know the best way to pass a variable-sized array from C to Java with SWIG (or any way at all)?

هل كانت مفيدة؟

المحلول

I tried to make a custom typemap in SWIG, but I got segfaults when I did that.

I eventually solved the problem by writing a new function in straight JNI that puts the array elements into a jlongArray, rather than letting SWIG write a wrapper function for it.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top