void pointers with SWIG

Steve Hanawalt stevehanawalt at yahoo.com
Wed Mar 12 17:51:26 EST 2003


Hello,

I've been trying to use SWIG to gain access to a DLL from a 3rd party
which I don't have the source code for, but I do have the .dll, the
.h, and the .lib.  The .h contains many functions such as:

FT_STATUS FT_ListDevices(
     PVOID pvArg1,
     PVOID pvArg2,
     DWORD Flags
     );

pvArg1 and pvArg2 can be both inputs and outputs depending on the
value of Flags.  A typical C call to this function would be:

FT_STATUS ftStatus;
DWORD numDevs;

ftStatus = FT_ListDevices(&numDevs,NULL,FT_LIST_NUMBER_ONLY);

If all works as expected, the number of devices connected is placed
into numDevs..

Alternatively if the function is called as:

FT_STATUS ftStatus;
char *BufPtrs[3];
char Buffer1[64];
char Buffer2[64];
DWORD numDevs;

BufPtrs[0] = Buffer1;
BufPtrs[1] = Buffer2;
BufPtrs[2] = NULL;

ftStatus = FT_ListDevices(BufPtrs,&numDevs,FT_LIST_ALL|FT_OPEN_BY_DESCRIPTION);

If all works as expected, the number of devices connected is placed
into numDevs and product descriptions are placed into Buffer1 and
Buffer2.

I've tried various typemaps, but I can't seem to get it to work.  I
keep getting an error in Python like: "Expected _p_PVOID"

Anyone been through this already that can provide me with the proper
insight.  I'm very new to SWIG and still fairly new to Python.

Thanks in advance.
Steve




More information about the Python-list mailing list