[PyKDE] SIP 3.10 problems

Phil Thompson phil at riverbankcomputing.co.uk
Fri Feb 27 20:37:01 GMT 2004


On Friday 27 February 2004 19:14, Claus, Richard wrote:
> Windows:
> Microsoft Development Environment 2003, version 7.1.3088
> Microsoft Visual C++ .NET   69462-270-0000007-18739
>
> C:\test>sip -V
> 3.10 (3.10-171)
>
> Excerpted from my code:
> OSWtimeContribution.h:
> class DLL_EXPORT_API OSWtimeContribution
> {
> public:
>   OSWtimeContribution()  {}
>   ~OSWtimeContribution() {}
>
>   void timebase(unsigned* tb) const { tb[0] = _timebase[1];
>                                       tb[1] = _timebase[0]; }
>
> private:
>   unsigned _timebase[2];
> };
>
> OSWtimeContribution.sip version 1:
> %ModuleHeaderCode
> #include "OSWtimeContribution.h"
> %End
>
>
> class OSWtimeContribution
> {
> public:
>   OSWtimeContribution();
>   ~OSWtimeContribution();
>
>   void timebase(unsigned* /*tb*/)  const;
> %MemberCode
>     OSWtimeContribution* sipCpp;
>     unsigned*            a0;
>
>     if (sipParseArgs(&sipArgsParsed,sipArgs,"mi",
> sipThisObj,sipClass_OSWtimeContribution,&sipCpp, &a0)) {
>       Py_BEGIN_ALLOW_THREADS
>       sipCpp -> timebase(a0);
>       Py_END_ALLOW_THREADS
>     }
> %End
> };
>
> sip -w gives:
> sip: Warning: ../sip/OSWtimeContribution.sip:23: %MemberCode is deprecated,
> please use %MethodCode instead
>
> Changing %MemberCode to %MethodCode gives a crash:
> The instruction at "0x00404d64" refrenced memory at "0x00000000".  The
> memory could not be "read".
>
> Following a suggestion from Jim Bublitz, I think the following should work:
> OSWtimeContribution.sip version 2:
> %ModuleHeaderCode
> #include "OSWtimeContribution.h"
> %End
>
>
> class OSWtimeContribution
> {
> public:
>   OSWtimeContribution();
>   ~OSWtimeContribution();
>
>   void timebase(unsigned* /Out/)  const;
> };
>
> This gives the same crash at 0x00404d64.
>
> Changing /Out/ to /In/ above allows "successful" compilation, but seems
> wrong.  Does the Out/In qualifier refer to the pointer or what it points
> to?

/In/ means the pointer points to a value being passed to the function.

/Out/ means the function will return a value via the pointer.

/In,Out/ means both.

The default in this case is /Out/.

It would be worth you trying a current snapshot if you still have problems as 
there have been fixes in this area.

> Also, in the full project I get lots of the following from sip generated
> code during "successful" compilation:
> c:\online\ebf\vs.net2003\sipebftkrcontribution.cpp(71) : warning C4700:
> local variable 'sipRes' used without having been initialized
>
> c:\online\ebf\vs.net2003\sipebfaemheader.cpp(64) : warning C4700: local
> variable 'a0' used without having been initialized
>
> c:\online\ebf\sipebflatcontributioniterator.cpp(68) : warning C4715:
> 'sipLATcontributionIterator::EBF' : not all control paths return a value

These are benign. If you used SIP v4 you shouldn't see any warnings.

Phil




More information about the PyQt mailing list