GnuCOBOL currently only works with mpir if gmpcompat is used. Because of 
some items in our central header file libcob.h being mpz_t we had gmp.h 
included - the definitions needed for mpz_t are the only reason including 
it there.

There are four possible ways I can think of to change that:

1) create libob.h from libcob.h.in during configure, placing either gmp.h 
or mpir.h in - biggest disadvantage is that you'd always need to create 
libcob.h if you use a source/svn tarball and add the creation of libcob.h 
to the vc-builds

2) use gmp.h or mpir.h depending on a define which is set during configure
#ifdef HAVE_GMP_H
#include <gmp.h>
#elif defined (HAVE_MPIR_H)
#include <mpir.h>
/* maybe add something here like
#else
#pragma error "either HAVE_GMP_H or HAVE_MPIR_H have to be defined"
*/ 
#endif
Biggest disadvantage: external programs would have to add the define and 
therefore may be broken with the changed version

3) use mpir.h depending on a define which is set during configure, use 
gmp.h in all other cases
#ifndef HAVE_MPIR_H
#include <gmp.h>
#else
#include <mpir.h>
#endif
Biggest disadvantage: if GnuCOBOL was build with mpir while gmp.h (version 
4.1 or version 6+) is available there may occur compatibility problems - at 
worst during runtime only (Is there any knowledge about that?)

4) use gmp.h or mpir.h depending on a define which is set during configure, 
if both defines are not set add the definition for mpz_t.
#ifdef HAVE_GMP_H
#include <gmp.h>
#elif defined (HAVE_MPIR_H)
#include <mpir.h>
#else
/* Definition of mpz_t (used in common.h)
   borrowed from MPIR 2.6.0
*/
#ifndef __GNU_MP__
typedef struct
{
  int _mp_alloc;        /* Number of *limbs* allocated and pointed
                   to by the _mp_d field.  */
  int _mp_size;            /* abs(_mp_size) is the number of limbs the
                   last field points to.  If _mp_size is
                   negative this is a negative number.  */
  unsigned int *_mp_d;        /* Pointer to the limbs.  */
} __mpz_struct;
#endif /* __GNU_MP__ */
typedef __mpz_struct mpz_t[1];
#endif
Biggest disadvantage: The definition of mpz_t may (???) not be correct on 
all systems with all versions of gmp.h / mpir.h. Same possible 
compatibility problems as with 3)

I'd like to read about your thoughts and good-practices from other projects.
Thank you for your time to answer.

Simon

-- 
You received this message because you are subscribed to the Google Groups 
"mpir-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to mpir-devel+unsubscr...@googlegroups.com.
To post to this group, send email to mpir-devel@googlegroups.com.
Visit this group at http://groups.google.com/group/mpir-devel.
For more options, visit https://groups.google.com/d/optout.

Reply via email to