ctypes and gmp
Miki
miki.tebeka at gmail.com
Thu Mar 27 14:17:43 EDT 2008
Hello All,
Playing around with ctypes, I'm try to use gmp (gmpy is excellent but
I want to learn ctypes).
I'm running:
#!/usr/bin/env python
from ctypes import *
class mpz(Structure):
_fields_ = [
("_mp_alloc", c_int),
("_mp_size", c_int),
("_mp_d", POINTER(c_uint)),
]
gmp = cdll.LoadLibrary("libgmp.so")
m = mpz()
gmp.__gmpz_init(byref(m))
gmp.__gmpz_set_ui(byref(m), 27)
gmp.__gmp_printf("m is %d\n", byref(m))
However, the output is:
m is -1210863888
Any ideas?
(gmp.h can bee view at http://tinyurl.com/yrqen4)
Thanks,
--
Miki <miki.tebeka at gmail.com>
http://pythonwise.blogspot.com
More information about the Python-list
mailing list