[PyKDE] Two minor sip issues

Phil Thompson phil at riverbankcomputing.co.uk
Sun Jun 19 15:48:36 BST 2005


On Sunday 19 June 2005 3:21 pm, Gerard Vermeulen wrote:
> Phil
>
> (1 ) sip.h contains the lines
>
> #if !defined(ANY)
> #define ANY     void
> #endif
>
> and as far as I can see, ANY isn't used anywhere by SIP or its generated
> code. However, it pollutes the global namespace with nasty side effects, eg
> enum { ANY = 0 };
> is preprocessed to
> enum { void = 0 };

It's used by handwritten code that wants to support older versions of Python. 
PyQt has 40+ references to it. I'd suggest #undef'ing it.

> (2) Since I like to have my extensions compatible with different versions
> of SIP and since changes are introduced with snapshots, I like to see a
> #define SIP_BUILD_NUMBER in sip.h.
>     This makes it easier to write code like:
>
>     virtual ~SoGroup();
> %MethodCode
> #if SIP_BUILD_NUMBER < 320
>     SoGroup *sipCpp = reinterpret_cast<SoGroup*>(sipSelf->u.cppPtr);
> #endif // SIP_BUILD_NUMBER < 320
> ...
> %End
>
> where SIP_BUILD_NUMBER has been figured out from calling 'sip -V'.
> (SIP_BUILD being a string, I failed to use it in comparisons, if possible
> at all).
>
> An alternative is to put sip_build and/or sip_build_str in sipconfig.py

No. A build is just a CVS commit tag. I don't even guarantee that it is a 
number. I wouldn't recommend trying to support separate builds - things can 
go into one one build, go away with another, and come back yet again later 
on.

Phil




More information about the PyQt mailing list