[PyQt] SIP snapshots do not handle typedef as SIP-4.7.7

Phil Thompson phil at riverbankcomputing.com
Mon Oct 27 09:27:14 GMT 2008


On Mon, 27 Oct 2008 06:14:13 +0100, Gerard Vermeulen <gav451 at gmail.com>
wrote:
> Hi,
> 
> I have .sip files like :
> 
> class TripleField
> {
> 
> %TypeHeaderCode
> #include <qwt3d_types.h>
> #include <sip_Qwt3DTriple.h>
> using namespace Qwt3D;
> %End // %TypeHeaderCode
> 
> public:
>     TripleField();
>     TripleField(size_type);
>     TripleField(size_type, const Triple &);
>     TripleField(const TripleField &);
> 
>     size_type capacity() const;
> ...
> }; // class TripleField
> 
> and size_type defined in a .sip file like:
> 
> // Automagically generated by configure.py
> 
> // Uncomment one of the following three lines
> // typedef unsigned int size_type;
> typedef unsigned long size_type;
> // typedef unsigned long long size_type;
> 
> The code generated by the latest SIP snapshots lead to
> compilation errors:
> 
> sip_Qwt3Dpart1.cpp: In function ‘PyObject*
> meth_TripleField_capacity(PyObject*, PyObject*)’:
> sip_Qwt3Dpart1.cpp:9604: error: ‘size_type’ was not declared in this
> scope
> sip_Qwt3Dpart1.cpp:9604: error: expected `;' before ‘sipRes’
> 
> I have to add a line
> typedef size_t size_type;
> in the TypeHeaderCode above to make it compile.
> 
> Is this a bug or a feature?

The latest SIP tries to use the original typedef name (rather than the type
it expands to) wherever possible in the generated code. This makes it
easier to support feature specific typedefs (eg. not all platforms
implement qreal as the same time).

The change should make no difference so long as the .h files being wrapped
properly contain the typedef (and SIP properly includes those files).

So where is size_type defined in your library?

Phil


More information about the PyQt mailing list