(This is the question I asked yesterday, but I simplified it)
I created a class from which I want two objects to be the output arguments of a function (called Test below). But when I run the swig command swig -C ++ -python swigtest.i, I get the error message “Warning 453: Can not apply (MyClass & OUTPUT). I tried adding typemaps, but that doesn't help. I also tried using pointers pointers to pointers and links to pointers, which also does not help.
It seems to me that I missed something simple, because this should be a fairly common thing. Or do I need to write a complex map, as I saw, but don’t understand (yet)?
Below is my code:
MyClass.h (simplified to make it clear, so switching to just int doesn't help):
class MyClass
{
int x;
public:
int get() const
{
return x;
}
};
void Test(MyClass &obj1, MyClass &obj2);
swigtest.i:
%module swigtest
%include typemaps.i
%{
#define SWIG_FILE_WITH_INIT
%}
%{
#include "MyClass.h"
%}
%include "MyClass.h"
%apply (MyClass& OUTPUT) { MyClass &obj1 }
%apply (MyClass& OUTPUT) { MyClass &obj2 }
source
share