En Wed, 22 Oct 2008 19:10:27 -0200, Philip Semanchuk
<[EMAIL PROTECTED]> escribió:
I'm writing a Python extension in C that wraps a function which takes a
void * as a parameter. (The function is shmat() which attaches a chunk
of shared memory to the process at the address supplied by the caller.)
I would like to expose this function to Python, but I don't know how to
define the interface.
Specifically, when calling PyArg_ParseTuple(), what letter should I use
to represent the pointer in the format string? The best idea I can come
up with is to use a long and then cast it to a void *, but assuming that
a long is big enough to store a void * is a shaky assumption. I could
use a long long (technically still risky, but practically probably OK)
but I'm not sure how widespread long longs are.
Are you *really* sure you want to supply a specific address argument? Most
of the time (if not always, unless you're doing really low level stuff) a
NULL is perfectly adequate.
Anyway, if it's going to be called from Python, the argument will be a
Python integer (or long) object); you may get the value using
PyInt_AsSsize_t
--
Gabriel Genellina
--
http://mail.python.org/mailman/listinfo/python-list