[ctypes-users] Re: Dereferencing a pointer
Brought to you by:
theller
|
From: Thomas H. <th...@py...> - 2004-07-06 20:10:51
|
Bryan D Rosander <bdr...@ju...> writes:
> I am currently working with pyFMOD (python extensions to FMOD, a sound
> library) to add callback functionality to the python library. Several
> functions in FMOD/pyFMOD return void pointers, notably the callback
> functions
[...]
> #The next function had a void return type. I'm not sure how to do that
> in ctypes.
With ctypes CVS, you could use None as return type. Doesn't work in
0.6.3, but you can probably use c_int instead, and ignore the result.
> This is the error I get
> Traceback (most recent call last):
> File "C:\Source\Python\pyDanceR\fmodTest.py", line 1, in ?
> import pyFMOD
> File "C:\PYTHON23\lib\site-packages\pyFMOD.py", line 6, in ?
> _FSOUND_DSPCALLBACK = CFUNCTYPE(c_void_p, pointer(c_int),
> pointer(c_int), c_int, c_int)
> File "C:\PYTHON23\Lib\site-packages\ctypes\__init__.py", line 206, in
> pointer
> return POINTER(type(inst))(inst)
> File "C:\PYTHON23\Lib\site-packages\ctypes\__init__.py", line 189, in
> POINTER
> {'_type_': cls})
> TypeError: _type_ must have storage info
Somewhat similar problem as another poster had: pointer() is a function
creating instances of ctypes' types. So, pointer(c_int) throws an
error, you should use pointer(c_int(32)) to create an instance of a
pointer pointing to the integer 32.
But, in the CFUNCTYPE call, you need ctypes' types, not ctypes'
instances. That's what POINTER creates:
_FSOUND_DSPCALLBACK = CFUNCTYPE(c_void_p, POINTER(c_int), c_int, c_int)
Hope that helps,
Thomas
|