Re: How to get binary data to callback function
Nikolaus Rath <[email protected]>
| Newsgroups | gmane.comp.python.ctypes |
|---|---|
| Message-ID | <[email protected]> |
Nikolaus Rath <[email protected]> writes: > "Martin (gzlist)" <[email protected]> writes: >> On 22/12/2009, Nikolaus Rath <[email protected]> wrote: >>> >>> When I define a callback function with a prototype of >>> >>> ctypes.CFUNCTYPE(None, ctypes.c_char_p, ctypes.c_int) >> >> You have the prototype wrong, c_char_p is for null-terminated strings: >> >> <http://docs.python.org/library/ctypes.html#ctypes.c_char_p> >> >> You want to use `ctypes.POINTER(ctypes.c_char)` instead for the definition. > > Ah, tricky. Thanks for helping out. I have just submitted a doc patch to make > this more clear (http://bugs.python.org/issue7569). This actually leads to a new question. How can I construct a POINTER(c_char)? c_char_p('string') works nicely, but POINTER(c_char)('string') raises a TypeError. What's the trick that I need here? Thanks, -Nikolaus -- »Time flies like an arrow, fruit flies like a Banana.« PGP fingerprint: 5B93 61F8 4EA2 E279 ABF6 02CF A9AD B7F8 AE4E 425C ------------------------------------------------------------------------------ This SF.Net email is sponsored by the Verizon Developer Community Take advantage of Verizon's best-in-class app development support A streamlined, 14 day to market process makes app distribution fast and easy Join now and get one step closer to millions of Verizon customers http://p.sf.net/sfu/verizon-dev2dev _______________________________________________ ctypes-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/ctypes-users