[PyQt] SIP beginner question(s) -- how to wrap typedef struct?

Phil Thompson phil at riverbankcomputing.com
Fri Aug 19 16:14:07 BST 2011


On Fri, 19 Aug 2011 10:28:44 -0400, Robin M Baur <rmb62 at cornell.edu>
wrote:
> Hi list,
> 
> I'm just getting started with SIP and have a few questions that I
> haven't yet found the answers to in the docs. Pointers back to the
> docs are welcome if I've missed something obvious. A standalone
> representative snippet of my header file is at the bottom of this
> email.
> 
> 1. Mainly, I'm searching for the correct combination of directives to
> wrap a typedef struct statement, assuming that's possible. (Is it?) I
> can wrap typedefs and structs individually, but I've been stymied in
> the attempt to do both together. I've tried both doing nothing and
> putting a %TypeHeaderCode directive inside the struct definition;
> either way, SIP just complains of a syntax error on the line with the
> opening brace. Should I be looking at %MappedType? Something else?

Use C++ syntax...

struct SERIAL_INIT_TS {
    ...
};

> 2. Is %UnitCode the correct directive for wrapping #pragma and
> #define? If not, what is?

Tell SIP it is an int...

const int API_OK;

> 3. My (Windows) compiler (MSVC 9.0) doesn't balk at UINT32, but SIP
> understandably does ("UINT32 is undefined."). MSVC 9 inexplicably
> doesn't ship stdint.h, so I can' t pull the obvious trick of
> #including stdint.h and replacing UINT32 with uint32_t everywhere.
> Does anyone know of a workaround for getting a UINT32 wrapped with
> SIP?

typedef unsigned UINT32;

It doesn't matter that they types aren't an exact match because Python has
no corresponding type anyway.

Phil


More information about the PyQt mailing list