[PyKDE] Special-case handling for default argument of NULL vs 0?

Phil Thompson phil at riverbankcomputing.co.uk
Tue Feb 21 23:09:35 GMT 2006


On Tuesday 21 February 2006 9:14 pm, Nigel Stewart wrote:
> Hi all,
>
> We're observing some issues with methods such as:
>
> (a)    void foo(const QString * = NULL);
> (b)    void bar(const QString * = 0);
>
> We're using Sip 4.3.2, it appears that Sip doesn't
> support (a), PyQt 3.15.1 doesn't use (a) and the
> yacc parser that sip uses is confusing NULL for
> a C++ identifier that the address can be taken of:
>
> static PyObject *meth_MyClass_foo(PyObject *sipSelf,PyObject *sipArgs)
> ...
> 		const QString * a0 = &NULL;       // Can't compile this!
>
> static PyObject *meth_MyClass_bar(PyObject *sipSelf,PyObject *sipArgs)
> ...
> 		const QString * a0 = NULL;
>
> So, the lesson seems to be that "= 0" is good, "= NULL" is
> to be avoided, when it comes to sip bindings.

And when it comes to C++ according to Stroustrup.

> But, it would be nice if sip could recogise NULL as a special
> case, since that is what we encourage in our C++ API, rather than
> "0".
>
> Any thoughts?

No problem with adding this.

Phil




More information about the PyQt mailing list