I have used typemaps :
%include "typemaps.i"
%apply SWIGTYPE * {char *deci};
This is the proxy class generated by SWIG:
public class SWIGTYPE_p_char {
private long swigCPtr;
protected SWIGTYPE_p_char(long cPtr, boolean futureUse) {
swigCPtr = cPtr;
}
protected SWIGTYPE_p_char() {
swigCPtr = 0;
}
protected static long getCPtr(SWIGTYPE_p_char obj) {
return (obj == null) ? 0 : obj.swigCPtr;
}
}
it seems trivial, but have you tried:
after all, all that the class contains is a long int representation of the pointer address
clearly you can only use this for a c function that returns a char* or uses a char* parameter as a pseudo return value
if you want to use a char* input parameter then you’ll most likely have to write a helper function of some sort
I wrapped this function prototype with SWIG recently:
which loaded data into my Config data-structure from a file specified by a string (char*)
I was able to call it from Java with the following line:
or alternatively: