bug-gmp
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Suggestions: mpz_export and version testing


From: Jack Lloyd
Subject: Suggestions: mpz_export and version testing
Date: Fri, 21 Nov 2003 02:55:55 -0500 (EST)

Hi,

I had a comment on the mpz_export function that would make it slightly
nicer (for me, anyway). When I'm using it, I know how long the result is
going to be, so the COUNT parameter is useless, but GNU MP requires it.
Currently I just create a size_t named dummy, pass it into mpz_export, and
then ignore it.  It would be nice if GNU MP would check if COUNT was NULL,
and not write to it in that case. Based on what I'm seeing in mpz/export.c,
this would simply involve putting "if(countp)" before the two assignments
to *countp that are in the function.

There is also a secondary thing. I would like it if something like the
following were included at the bottom of gmp.h:

#define __GNU_MP_VERSION_CODE ((__GNU_MP_VERSION << 16) | \
                               (__GNU_MP_VERSION_MINOR << 8) | \
                               (__GNU_MP_VERSION_PATCHLEVEL))

#define __GNU_MP_VERSION_CODE_FOR(a,b,c) ((a << 16) | (b << 8) | (c))

so my code could do things like:

#if __GNU_MP_VERSION_CODE < __GNU_MP_VERSION_CODE_FOR(4,1,0)
  #error Your GNU MP install is too old, upgrade to 4.1 or later
#endif

(well, it is already doing this, but I'm putting the first two #define's
into each of my source files after I include gmp.h). This would make
feature testing in (non-autoconf'ed) programs easier, for example to test
if mpz_export is available. I suppose you could also define the version
code in terms of the VERSION_CODE_FOR macro, I guess that would be a bit
cleaner.

Thanks,
  Jack





reply via email to

[Prev in Thread] Current Thread [Next in Thread]