ctypes question

News Wombat newswombat at gmail.com
Tue Dec 14 13:36:26 EST 2010


On Dec 11, 12:59 pm, MrJean1 <mrje... at gmail.com> wrote:

> In general, for shared libraries, you need to define those first as
> prototype using ctypes.CFUNCTYPE() and then instantiate each prototype
> once supplying the necessary parameter flags using
> prototype(func_spec, tuple_of_param_flags).  See sections 15.16.2.3
> and 4 of the ctypes docs*.

I tried the cfuntype and proto steps, and it's not crashing now
(that's good), but now i'm just left with null pointers as a return
object.  I'm still working through all of the examples you sent.  They
were extremely helpful.  Here's where I'm at now...

What is strange is I can actually get smiGetNode to work if I don't
cfunctype/proto it.  If i do, nada.  however, the smiGetNextNode fails
no matter what, usually with a segfault, but depending on how i
construct it, sometimes a null pointer.

constants.py: http://pastebin.com/f3b4Wbf0
libsmi.py: http://pastebin.com/XgtpG6gr
smi.c (the actual function): http://pastebin.com/Pu2vabWM



More information about the Python-list mailing list