Claudio Ferraro
Claudio Ferraro

Reputation: 4721

How to pass a value to a function when the value is SWIGTYPE

I have a wrapped function in java like this:

dosomething(SWIGTYPE_sometypeSTRUCT STRUCTtype);

Originally in the C code, the declaration looks so:

dosomething(sometypeSTRUCT* structtype);

How can I pass the SWIGTYPE to the java function. if I do: SWIGTYPE_sometypeSTRUCT something = new SWIGTYPE_sometypeSTRUCT ();

it won't work.. It will work only if I set somthing = null.

Upvotes: 0

Views: 315

Answers (1)

The problem is that SWIG hasn't seen a definition of sometypeSTRUCT - as far as it knows the pointer your dosomething function takes is an opaque type.

When SWIG doesn't know details it can't wrap it meaningfully and the only safe thing to do is let you do what you would be able to do in C with such a type.

To fix this you probably want to use %include to bring in the definition of the struct, or possibly provide a definition within the SWIG interface file.

Upvotes: 1

Related Questions