[ctypeslib] generate POINTER(c_char) instead of c_char_p (was: Simple way to call a function with struct flockargument [SEC=PERSONAL])

Nikolaus Rath <[email protected]>
Newsgroups gmane.comp.python.ctypes
Message-ID <[email protected]>
"Andrew MacIntyre" <[email protected]> writes:
> Pyrex and Cython are packages which can be used to build C extensions 
> more easily than writing the C interface code by hand (or trying to 
> write Python+ctypes code for complex cases), but you still need 
> to build extension modules for each platform supported.
>
> Your expectations of ctypes are beyond its capability.  However 
> there is at least one tool available to do some of the grunt work of 
> analysing C header files for you: ctypeslib - see the "Related projects"
> section of http://starship.python.net/crew/theller/ctypes/.

I have played around with Py++, ctypeslib, Cython, SWIG and bare Python
extensions for a while now. It seems that the first two are most
suitable for my purpose and I managed to autogenerate ctypes interface
code with both of them.

Py++ seems to be much more powerful than ctypeslib, but I don't really
need much of that power. However, I quickly discovered two critical bugs
in Py++ as well (I'm not complaining about that, it's unreleased code
after all), which makes me think that ctypeslib might be a bit more
reliable (it's also unreleased, but I hope that less power may also come
with less bugs).

But to come to my actual question:

By default, ctypeslib translates char* into c_char_p. But, as I just
learned on this list, this only works for \0 terminated strings. Is
there a way to make ctypeslib use POINTER(c_char) instead?

There is a promising 'STRING = c_char_p' at the beginning of the
autogenerated file, but I couldn't find a documented way to change this.

Best,


   -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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.