Search code examples
javac++java-native-interfaceswigfreeimage

C++ Function with pointer as parameter and Handle it with swig interface


I have created swig interface file to create JNI for my C++ Files. but some of my C++ Files include functions which accept pointer as argument like (void*) , C++ BOOL and Swig converts it into type like SWIGTYPE_p_int32_t how to pass such kind of data type from java ?

for example one of the function's actual prototype is like below in C++

DLL_API void DLL_CALLCONV FreeImage_Initialise(BOOL load_local_plugins_only FI_DEFAULT(FALSE));

which is converted in Java file with swig

public static void FreeImage_Initialise(SWIGTYPE_p_int32_t load_local_plugins_only)

how to pass such value from java ?

I have many classes which include such kind of arguments in function. is there any way so that I can apply solution to bulk files for handle datatype as simple as possible.

I have read one way to do that is create helper function but I cannot go for it because i have many c++ classes and for each and every function creating helper function for returning pointer is not way to go.

Please suggest any other way if possible.


Solution

  • Solved myself. Swig was not be able to recognize all the typedef in header files and hence it was producing that kind of Types in wrapper. I need to redefine them in Interface file.