On Mon, Mar 2, 2009 at 1:31 PM, Justin Holewinski <
shawmishrak <at> gmail.com> wrote:
> The errors do not occur with Python 2.6.1 and 2.7 (SVN trunk), nor with
> Stackless Python 2.6.1. The error does occur with Python 3.0.1 (release or
> Python 3.0 SVN branch), Python 3.1 (SVN branch), and Stackless Python 3.0.1,
> all built from source.
>
> At least one of the problems seems to be the lack of a cmpfunc typedef in
> Python 3.x. I don't know the Python C API well enough to know what exactly
> changed, but most of the compile errors are a result of this missing
> typedef. However, even if I manually insert that typedef, I still get a
> couple of the compile errors, namely the first one.
>
> The SWIG/Python examples also fail to build with the same errors if I target
> a 3.x installation of Python. These are with unmodified Python
> distributions from
python.org and/or
stackless.com.
>
> On Mon, Mar 2, 2009 at 12:08 AM, Haoyu Bai <
divinekid <at> gmail.com> wrote:
>>
>> On Mon, Mar 2, 2009 at 5:41 AM, Justin Holewinski <
shawmishrak <at> gmail.com>
>> wrote:
>> > I am trying to use SWIG with Python 3.0.1, but the generated wrapper
>> > code is
>> > not compiling against the Python 3.0.1 API. GCC gives the following
>> > errors:
>> >
>> > MyClass_wrap.cxx: In function ‘PyTypeObject* _PySwigObject_type()’:
>> > MyClass_wrap.cxx:1747: error: invalid conversion from ‘PyObject*
>> > (*)(PyObject*)’ to ‘void*’
>> > MyClass_wrap.cxx:1772: error: ‘cmpfunc’ was not declared in this scope
>> > MyClass_wrap.cxx:1772: error: expected `}' before ‘SwigPyObject_compare’
>> > MyClass_wrap.cxx:1772: error: expected ‘,’ or ‘;’ before
>> > ‘SwigPyObject_compare’
>> > MyClass_wrap.cxx:1818: error: ‘tmp’ was not declared in this scope
>> > MyClass_wrap.cxx: At global scope:
>> > MyClass_wrap.cxx:1825: error: expected unqualified-id before ‘return’
>> > MyClass_wrap.cxx: In function ‘PyTypeObject* _PySwigPacked_type()’:
>> > MyClass_wrap.cxx:1943: error: ‘cmpfunc’ was not declared in this scope
>> > MyClass_wrap.cxx:1943: error: expected `}' before ‘SwigPyPacked_compare’
>> > MyClass_wrap.cxx:1943: error: expected ‘,’ or ‘;’ before
>> > ‘SwigPyPacked_compare’
>> > MyClass_wrap.cxx:1989: error: ‘tmp’ was not declared in this scope
>> > MyClass_wrap.cxx: At global scope:
>> > MyClass_wrap.cxx:1996: error: expected unqualified-id before ‘return’
>> > MyClass_wrap.cxx:1997: error: expected declaration before ‘}’ token
>> >
>> >
>> > Visual Studio 2008 gives similar errors. I am invoking Swig as follows:
>> >
>> > $ /path/to/swig -c++ -python -py3 -Wall MyClass.i
>> >
>> >
>> > I have tried this with Swig 1.3.38 and the SVN trunk (revision 11141),
>> > and
>> > Python 3.0.1 and Stackless Python 3.0.1.
>> >
>> > Any ideas? Am I passing the wrong arguments to Swig?
>> >
>> >
>> > Thanks!
>> >
>>
>> Hi,
>>
>> I have regularly run SWIG's test suite with Python 3.x's SVN checkout,
>> and there's no such errors. Could you try to run it with Python 2.x
>> and see if there are still errors? And you may remove the -py3 option,
>> then the generated code can be compiled with both Python 2.x and 3.x.
>>
>> -- Haoyu Bai
>
>