bug-gmp
[Top][All Lists]
Advanced

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

Re: GMP compiled under MacOS/C++ wrap


From: Kevin Ryde
Subject: Re: GMP compiled under MacOS/C++ wrap
Date: 25 Apr 2001 08:13:19 +1000
User-agent: Gnus/5.0808 (Gnus v5.8.8) Emacs/20.5

Hans Aberg <address@hidden> writes:
>
> I compiled GMP <ftp://ftp.gnu.org/pub/gnu/gmp/gmp-3.0.tar.gz> generic under
> pre-MacOS X with Metrowerks CodeWarrior Pro 5 C/C++ compiler, using the
> 32-bit gmp-mparam.h header. (Note that the Mac G4 CPU is 128 bit, and there
> appears to be no header for that.)

Does the Makefile and configure in the macos directory help?

> I started on a C++ wrap, classes gmp::integer, gmp::rational, gmp::floating
> that expand to the GMP C functions. If you are interested, please let me
> know. I don not plan to write all GMP functions into that wrap, but it
> would not be difficult to do so. (More info below.)

Gerardo Ballabio has made good progress on such a wrapper,

        http://www.sissa.it/~ballabio/gmp++.html

> - When making C++ classes, it would be natural to put in a reference count,
> in order to avoid unnecessary copying.

I thought heavy objects were best passed around by reference (but I'm
not a c++ expert).

> But at least under C++, a ref-count seems reasonable, because arithmetic
> operators can return gmp::integer, gmp::rational, and gmp::floating values
> without calling a new dynamic allocation.

An alternative is to keep a bit of a free list of initialized mpz_t or
mpq_t's.  Could probably be thread safe with some care.  Doesn't work
so well for mpf_t unless you're using the same precision everywhere.

> My impression from reading this comment was that you had put in
> "defined(__cplusplus)" just in order to make it work for Sun C/C++ (but I
> perhaps read it wrong). But it is normal to not have __STDC__ defined under
> C++.

The comment has since been clarified:

/* Sun workshop C 5.0 requires "##" for token pasting, but defines __STDC__
   to 0, hence the use of defined(__STDC__) rather than __STDC__-0.  */
#ifndef __MPN
#if defined (__STDC__) || defined (__cplusplus)
#define __MPN(x) __gmpn_##x
#else
#define __MPN(x) __gmpn_/**/x
#endif
#endif



reply via email to

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