Public mpz_ptr and mpz_srcptr

Niels Möller nisse at lysator.liu.se
Mon Feb 4 11:31:15 CET 2013


gmp.h includes the following:

  /* Types for function declarations in gmp files.  */
  /* ??? Should not pollute user name space with these ??? */
  typedef const __mpz_struct *mpz_srcptr;
  typedef __mpz_struct *mpz_ptr;

I'm afraid there's no better type for users, when writing code which
returns a pointer to an mpz variables. E.g,

  mpz_t
  foo (mpz_t x)
  {
    return x;
  }

seems to give a compilation error (returning an array). While

  mpz_ptr
  foo (mpz_ptr x)
  {
    return x;
  }

should work fine. Or otherwise, handling pointers in any variable which
isn't a formal parameter to a function. Using mpz_t * (pointer to an
array) isn't a good alternative, since you'd get a harsh warning
whenever passing such a pointer to a GMP function expecting an mpz_ptr.

Or is there any better way to write the return type which I have missed?
I take it MP_INT * and __mpz_struct * are both discouraged.

Regards,
/Niels

-- 
Niels Möller. PGP-encrypted email is preferred. Keyid C0B98E26.
Internet email is subject to wholesale government surveillance.



More information about the gmp-devel mailing list