[Patch] Fix build problem of GMP 4.2.1 with Sun Studio 11
Matthias Koeppe
mkoeppe at mail.math.uni-magdeburg.de
Fri Jul 21 16:46:29 CEST 2006
I wrote:
> I am trying to build GMP 4.2.1 with --enable-cxx using the Sun
> Studio 11 compilers on Solaris 9/SPARC [...]
> CC: Sun C++ 5.8 Patch 121017-02 2006/04/19
>
> The build fails for cxx/ismpf.cc and cxx/osmpf.cc as follows:
> "cxx/ismpf.cc", line 55: Error: Could not find a match for std::use_facet<std::Facet>(const std::locale) needed in operator>>(std::istream &, __mpf_struct*).
I have now come up with a patch, following examples from Sun
documentation, that fixes the above problems. The problem seems to be
that the Sun compilers cannot do dispatch on the return type, so a
different flavor of std::use_facet needs to be used.
I hope the patch is useful for other people as well.
diff -c -r /home/mkoeppe/w/latte/distro/gmp-4.2.1.orig/cxx/ismpf.cc gmp-4.2.1/cxx/ismpf.cc
*** /home/mkoeppe/w/latte/distro/gmp-4.2.1.orig/cxx/ismpf.cc Tue Mar 14 16:57:54 2006
--- gmp-4.2.1/cxx/ismpf.cc Fri Jul 21 16:18:35 2006
***************
*** 52,58 ****
// C++ decimal point
#if HAVE_STD__LOCALE
const locale& loc = i.getloc();
! char point_char = use_facet< numpunct<char> >(loc).decimal_point();
#else
const char *point = lconv_point;
char point_char = *point;
--- 57,69 ----
// C++ decimal point
#if HAVE_STD__LOCALE
const locale& loc = i.getloc();
! char point_char =
! #ifndef _RWSTD_NO_TEMPLATE_ON_RETURN_TYPE
! use_facet< numpunct<char> >(loc)
! #else
! use_facet(loc,(numpunct<char>*)0)
! #endif
! .decimal_point();
#else
const char *point = lconv_point;
char point_char = *point;
***************
*** 64,70 ****
{
// C++ isspace
#if HAVE_STD__LOCALE
! const ctype<char>& ct = use_facet< ctype<char> >(loc);
#define cxx_isspace(c) (ct.is(ctype_base::space,(c)))
#else
#define cxx_isspace(c) isspace(c)
--- 75,86 ----
{
// C++ isspace
#if HAVE_STD__LOCALE
! const ctype<char>& ct =
! #ifndef _RWSTD_NO_TEMPLATE_ON_RETURN_TYPE
! use_facet< ctype<char> >(loc);
! #else
! use_facet(loc,(ctype<char>*)0);
! #endif
#define cxx_isspace(c) (ct.is(ctype_base::space,(c)))
#else
#define cxx_isspace(c) isspace(c)
diff -c -r /home/mkoeppe/w/latte/distro/gmp-4.2.1.orig/cxx/ismpz.cc gmp-4.2.1/cxx/ismpz.cc
*** /home/mkoeppe/w/latte/distro/gmp-4.2.1.orig/cxx/ismpz.cc Tue Mar 14 16:57:54 2006
--- gmp-4.2.1/cxx/ismpz.cc Fri Jul 21 16:19:14 2006
***************
*** 40,46 ****
if (i.flags() & ios::skipws) // skip initial whitespace
{
#if HAVE_STD__LOCALE
! const ctype<char>& ct = use_facet< ctype<char> >(i.getloc());
#define cxx_isspace(c) (ct.is(ctype_base::space,(c)))
#else
#define cxx_isspace(c) isspace(c)
--- 40,52 ----
if (i.flags() & ios::skipws) // skip initial whitespace
{
#if HAVE_STD__LOCALE
! const ctype<char>& ct =
! #ifndef _RWSTD_NO_TEMPLATE_ON_RETURN_TYPE
! use_facet< ctype<char> >(i.getloc());
! #else
! use_facet(i.getloc(),(ctype<char>*)0);
! #endif
!
#define cxx_isspace(c) (ct.is(ctype_base::space,(c)))
#else
#define cxx_isspace(c) isspace(c)
diff -c -r /home/mkoeppe/w/latte/distro/gmp-4.2.1.orig/cxx/osmpf.cc gmp-4.2.1/cxx/osmpf.cc
*** /home/mkoeppe/w/latte/distro/gmp-4.2.1.orig/cxx/osmpf.cc Tue Mar 14 16:57:54 2006
--- gmp-4.2.1/cxx/osmpf.cc Fri Jul 21 16:20:56 2006
***************
*** 46,52 ****
#if HAVE_STD__LOCALE
char point[2];
! point[0] = use_facet< numpunct<char> >(o.getloc()).decimal_point();
point[1] = '\0';
#else
const char *point = localeconv()->decimal_point;
--- 50,62 ----
#if HAVE_STD__LOCALE
char point[2];
! point[0] =
! #ifndef _RWSTD_NO_TEMPLATE_ON_RETURN_TYPE
! use_facet< numpunct<char> >(o.getloc())
! #else
! use_facet(o.getloc(),(numpunct<char>*)0)
! #endif
! .decimal_point();
point[1] = '\0';
#else
const char *point = localeconv()->decimal_point;
--
Matthias Koeppe -- http://www.math.uni-magdeburg.de/~mkoeppe
More information about the gmp-bugs
mailing list