_ptr and _srcptr types
Vincent Lefevre
vincent at vinc17.net
Wed May 16 13:07:18 UTC 2018
On 2018-05-16 14:04:02 +0200, Niels Möller wrote:
> It shouldn't be so difficult for users familiar with the fine points of
> arrays and pointers in C. mpz_t is a typedef for a size 1 array
> containing the internal struct, and mpz_ptr is a pointer to the same
> struct, i.e., the type that an mpz_t "decays" to in expression context.
Yes, and anyway, users could already ugly things without using mpz_ptr
explicitly (without any compiler warning):
#include <stdio.h>
#include <gmp.h>
int main (void)
{
mpz_t x, y;
void *p = x;
mpz_init (x);
mpz_init (y);
mpz_set_ui (x, 1);
mpz_set_ui (y, 2);
mpz_add (p, x, y);
gmp_printf ("%Zd\n", x);
mpz_clear (x);
mpz_clear (y);
return 0;
}
With mpz_ptr, it would just be a bit cleaner. And there are good
usages of mpz_ptr.
--
Vincent Lefèvre <vincent at vinc17.net> - Web: <https://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)
More information about the gmp-devel
mailing list