bug-gmp
[Top][All Lists]
Advanced

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

Bug Fix: _LONGLONG macro, Visual C++ 7.0


From: librik
Subject: Bug Fix: _LONGLONG macro, Visual C++ 7.0
Date: Sun, 23 Jun 2002 20:16:43 -0400 (EDT)

Use of the _LONGLONG macro in gmp-impl.h causes GMP 4.1 to fail to build
as C++ using Microsoft Visual C++ 7.0 (Visual C++ .NET).  A simple patch
fix is given below.

gmp-impl.h uses the _LONGLONG macro to determine whether the
compiler and target architecture has a native 64-bit type whose
name is "long long int".  (This is the standard GNU use of
_LONGLONG.  On 64-bit versions of GCC, _LONGLONG is defined to 1.)
>From "gmp-impl.h":
  #if defined _LONGLONG || defined _LONG_LONG_LIMB
  typedef       long long int DItype;
  typedef unsigned long long int UDItype;
  #else /* Assume `long' gives us a wide enough type.  Needed for hppa2.0w.  */
  typedef long int DItype;
  typedef unsigned long int UDItype;
  #endif

In Microsoft Visual C++ 7.0, _LONGLONG is defined as the name of
the 64-bit type, "__int64".  In Visual C++ 7's "yvals.h", we see:
  /* VC++ COMPILER PARAMETERS */
  #define _LONGLONG     __int64
  #define _ULONGLONG    unsigned __int64
  #define _LLONG_MAX    0x7fffffffffffffff
  #define _ULLONG_MAX   0xffffffffffffffff
"long long int" itself is not a valid type in Visual C++ 7.0.

__int64 is emulated, slowly, in the standard 32-bit Visual C++.
It shouldn't be used as a basic type, even though it exists.
Thus, the fact that _LONGLONG is defined doesn't mean that there
is necessarily a native 64-bit type; this is different in both
syntax and semantics from GCC.

The easiest patch for this is to change the sense of the #if:

  --- gmp-impl.h.old      Wed May 08 16:50:18 2002
  +++ gmp-impl.h  Tue Jun 18 18:25:28 2002
  @@ -2443,7 +2443,7 @@
   typedef unsigned char UQItype;
   typedef                 long SItype;
   typedef unsigned long USItype;
  -#if defined _LONGLONG || defined _LONG_LONG_LIMB
  +#if (defined _LONGLONG && !defined _MSC_VER) || defined _LONG_LONG_LIMB
   typedef        long long int DItype;
   typedef unsigned long long int UDItype;
   #else /* Assume `long' gives us a wide enough type.  Needed for hppa2.0w. */

At least this much is required to get GMP to build.

When there is a 64-bit Microsoft Visual C port of GMP, perhaps _LONGLONG
can be used.  (The 64-bit type, the native machine word, is __int64 in
64-bit Visual C.  "long int" is the same as "int" and "long long int"
is invalid.)   This is a larger and still-unplanned project, which will
probably require a Win64 version of Cygwin and some autoconf-script
enhancements.

- David Librik
address@hidden



reply via email to

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