Add a USING_MSVC6 macro to identify Microsoft Visual C++ 6.0
authorSteve Hay <steve.m.hay@googlemail.com>
Thu, 19 Sep 2013 13:27:10 +0000 (14:27 +0100)
committerSteve Hay <steve.m.hay@googlemail.com>
Thu, 19 Sep 2013 13:50:43 +0000 (14:50 +0100)
This simplifies some of the logic necessary for coping with its various
problems.

Suggested by Nicholas Clark.

handy.h
perl.h
util.h
win32/win32.h

diff --git a/handy.h b/handy.h
index 27fb18b..f80ba2c 100644 (file)
--- a/handy.h
+++ b/handy.h
@@ -125,7 +125,7 @@ Null SV pointer. (No longer available when C<PERL_CORE> is defined.)
 #if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || (defined(__SUNPRO_C)) /* C99 or close enough. */
 #  define FUNCTION__ __func__
 #else
-#  if (defined(_MSC_VER) && _MSC_VER < 1300) || /* MSVC6 has neither __func__ nor __FUNCTION and no good workarounds, either. */ \
+#  if (defined(USING_MSVC6)) || /* MSVC6 has neither __func__ nor __FUNCTION and no good workarounds, either. */ \
       (defined(__DECC_VER)) /* Tru64 or VMS, and strict C89 being used, but not modern enough cc (in Tur64, -c99 not known, only -std1). */
 #    define FUNCTION__ ""
 #  else
diff --git a/perl.h b/perl.h
index 0da8ed7..1e8e870 100644 (file)
--- a/perl.h
+++ b/perl.h
 #   endif
 #endif
 
+/* Microsoft Visual C++ 6.0 needs special treatment in numerous places */
+#if defined(WIN32) && defined(_MSC_VER) && _MSC_VER >= 1200 && _MSC_VER < 1300
+#  define USING_MSVC6
+#endif
+
 #undef START_EXTERN_C
 #undef END_EXTERN_C
 #undef EXTERN_C
@@ -1605,13 +1610,11 @@ typedef UVTYPE UV;
 #  else
 #    undef IV_IS_QUAD
 #    undef UV_IS_QUAD
-#ifndef PERL_CORE
+#if !defined(PERL_CORE) || defined(USING_MSVC6)
 /* We think that removing this decade-old undef this will cause too much
    breakage on CPAN for too little gain. (See RT #119753)
-   However, we do need HAS_QUAD in the core for use by the drand48 code.  */
-#    undef HAS_QUAD
-#elif defined(_MSC_VER) && _MSC_VER < 1300
-/* Undef HAS_QUAD in core for Win32 VC6 because it has poor __int64 support. */
+   However, we do need HAS_QUAD in the core for use by the drand48 code,
+   but not for Win32 VC6 because it has poor __int64 support. */
 #    undef HAS_QUAD
 #endif
 #  endif
diff --git a/util.h b/util.h
index 87a3f26..08544f5 100644 (file)
--- a/util.h
+++ b/util.h
@@ -55,12 +55,10 @@ This is a synonym for (! foldEQ_locale())
 /* outside the core, perl.h undefs HAS_QUAD if IV isn't 64-bit
    We can't swap this to HAS_QUAD, because the logic here affects the type of
    perl_drand48_t below, and that is visible outside of the core.  */
-#ifdef U64TYPE
-#  if !defined(_MSC_VER) || _MSC_VER >= 1300
+#if defined(U64TYPE) && !defined(USING_MSVC6)
 /* use a faster implementation when quads are available,
  * but not with VC6 on Windows */
 #    define PERL_DRAND48_QUAD
-#  endif
 #endif
 
 #ifdef PERL_DRAND48_QUAD
index 47a1dc6..79fe071 100644 (file)
@@ -246,7 +246,7 @@ typedef unsigned short      mode_t;
 #define snprintf       _snprintf
 #define vsnprintf      _vsnprintf
 
-#if _MSC_VER < 1300
+#ifdef USING_MSVC6
 /* VC6 has broken NaN semantics: NaN == NaN returns true instead of false */
 #define NAN_COMPARE_BROKEN 1
 #endif