handling an mpz-"array"

Peter Linder peter.linder at bfh.ch
Fri Oct 31 13:48:43 CET 2008


I have some issues handling multiple mpz_t's and I will try to explain  
it in the following lines:

As I could read in the gmp.h, the __mpz_struct struct is defined like  

typedef struct
   int _mp_alloc;		
   int _mp_size;			
   mp_limb_t *_mp_d;		
} __mpz_struct;

also there is the typedef declaration for mpz_t:

typedef __mpz_struct mpz_t[1];

now I tried to allocate to store several mpz_t's:

static mpz_t **storage;
storage = (mpz_t **)malloc(sizeof(mpz_t)*numberOfSlotsToStore);

and assign some initialized mpz_t's:

*preSlots = (mpz_t *)x;
*(preSlots+1) = (mpz_t *)y;
*(preSlots+2) = (mpz_t *)z;

now I would like to use to access them again to make further  

e.g. :  mpz_set(z,(mpz_t *)*preSlots);

what actually seems to work, but raises the following warning (gcc:  
i686-apple-darwin9-gcc-4.0.1 (GCC) 4.0.1 (Apple Inc. build 5465)):

"warning: passing argument 2 of '__gmpz_set' from incompatible pointer  

As I am no C expert I wanted to ask if this is something I should take  
care about or not?

I would be happy to know if there is a 'better' handling of multiple  

Best wishes


More information about the gmp-discuss mailing list