Philip Semanchuk schrieb: > 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.
I suggest "O!" and a converter function calling PyLong_AsVoidPtr(). Thomas -- http://mail.python.org/mailman/listinfo/python-list