From: Marco D. <mar...@gm...> - 2009-07-17 15:16:44
|
Hello, I'm getting this error message when wrapping a C++ library: *** glibc detected *** /usr/bin/python2.5: free(): invalid pointer: 0xb7df6b40 *** I use %extend to add a new constructor to a class, but for some reasons I don't understand the parent constructor of this class is never called. I managed to reproduce the problem with this simple example: class Foo { protected: Foo() { cout << "foo()" << endl; } ~Foo() { cout << "~foo()" << endl; } }; class Bar : public Foo { protected: Bar() { cout << "bar()" << endl; } public: ~Bar() { cout << "~bar()" << endl; } }; the SWIG file: %module test %{ #define SWIG_FILE_WITH_INIT #include <test.h> %} #include <iostream> %include <test.h> %extend Bar { Bar(int i) : Foo () { std::cout << "in extended bar constructor " << std::endl; } }; and a Python test file: #!/usr/bin/python2.5 import test as t class Woo(t.Bar) : def __init__(self): super(Woo, self).__init__(2) a = Woo() Executing the python file outputs: in extended bar constructor ~bar() ~foo() *** glibc detected *** /usr/bin/python2.5: free(): invalid pointer: 0xb7cd2b40 *** But I was expecting to see "foo()" at the beginning of the output...anybody cares to explain me what I'm doing wrong please ? Regards, MD |