[Insight-developers] ambiguous else warnings from CableSwig generated python interface code

Gaëtan Lehmann gaetan.lehmann at jouy.inra.fr
Wed Feb 9 15:30:43 EST 2011


Le 9 févr. 11 à 20:46, Wheeler, Frederick W (GE Global Research) a  
écrit :

> ITK list:
>
> When compiling ITK with Python wrappers using gcc 4.5.1 and -Wall I  
> get many (100s at least) warnings like this:
>
> /projects/IUP3/wheeler/dev/itk_bld_gcc_rel/Wrapping/WrapITK/ 
> Libraries/IntensityFilters/itkInvertIntensityImageFilterPython.cpp: 
> 4186:10: warning: suggest explicit braces to avoid ambiguous ∂ 
> ±else∂”
>
>    ~PySequence_Cont()
>    {
>      if (_seq) Py_DECREF(_seq); //***** this is line 4186
>    }
>
> Another sample:
>
>    PyObject_ptr(PyObject *obj, bool initial_ref = true) :_obj(obj)
>    {
>      if (initial_ref) Py_XINCREF(_obj); //***** warning emitted for  
> this line also
>    }
>
> Py_DECREF is a macro from Python include file object.h that looks  
> somethig like this:
>  #define Py_DECREF() if(...) { statements ... } else statement
> This is where the ambiguous else comes from, no {brackets} after the  
> else.
>
> If the above lines were changed like this, then I expect the  
> warnings would cease.
>
>    ~PySequence_Cont()
>    {
>      if (_seq) { Py_DECREF(_seq); }
>    }
>
> I've been trying to fix this but cannot figure out where this
> generated code is emitted.  I suspect SWIG/Source/Modules/python.cxx,
> but after much searching I cannot find where these warning-creating
> statements are generated.  This seems like it should be an easy fix
> and worth fixing.  If that is the case and someone can point me toward
> the place where this code is created I'll produce and test a patch,
> which may be quite trivial as I think only two pairs of brackets are
> needed.
>
>
> Generated lines like this also yield a warning: /projects/IUP3/ 
> wheeler/dev/itk_bld_gcc_rel/Wrapping/WrapITK/Libraries/ 
> UnaryPixelMath/itkExpNegativeImageFilterPython.cpp:2172:48: warning:  
> deprecated conversion from string constant to ∂±char*∂”
>
> dict = PyObject_GetAttrString(inst, "__dict__");
>
> But here I think the problem is PyObject_GetAttrString expects a  
> char* for arg 2 in older versions of python (I'm using 2.4).


Hi Fred,

I can't find anything like this piece of code in my WrapITK build.

Which version of swig are you using?

Have you tried to report the errors to the swig developers?
The swig developers are certainly more competent than anybody on this  
list when it comes to patching swig code!

Regards,

Gaëtan

-- 
Gaëtan Lehmann
Biologie du Développement et de la Reproduction
INRA de Jouy-en-Josas (France)
tel: +33 1 34 65 29 66    fax: 01 34 65 29 09
http://voxel.jouy.inra.fr  http://www.itk.org
http://www.mandriva.org  http://www.bepo.fr

-------------- next part --------------
A non-text attachment was scrubbed...
Name: PGP.sig
Type: application/pgp-signature
Size: 203 bytes
Desc: Ceci est une signature ?lectronique PGP
URL: <http://www.itk.org/mailman/private/insight-developers/attachments/20110209/1e8774d3/attachment.pgp>


More information about the Insight-developers mailing list