Restore VC++ 6 build on Windows
authorSteve Hay <steve.m.hay@googlemail.com>
Fri, 17 Aug 2012 23:33:53 +0000 (00:33 +0100)
committerSteve Hay <steve.m.hay@googlemail.com>
Fri, 17 Aug 2012 23:33:53 +0000 (00:33 +0100)
Commits bb02a38feb and 1bd3586145 resulted in VC++ 6 complaining "error
C2099: initializer is not a constant" when initializing bodies_by_type in
sv.c. Workaround the apparent compiler bug using a patch from Jan Dubois,
amended to be compiler-specific as suggested by Nicholas Clark since
anonymous unions are not valid C89.

Date: Wed, 15 Aug 2012 00:55:06 -0700
Message-ID: <005a01cd7abb$498294e0$dc87bea0$@activestate.com>

cv.h
pod/perldelta.pod
sv.h

diff --git a/cv.h b/cv.h
index e8cb162..cd722f3 100644 (file)
--- a/cv.h
+++ b/cv.h
@@ -66,7 +66,11 @@ S_CvDEPTHp(const CV * const sv)
 {
     return SvTYPE(sv) == SVt_PVCV
        ? &((XPVCV*)SvANY(sv))->xcv_depth
+#if defined(_MSC_VER) && _MSC_VER < 1300
+       : &((XPVCV*)SvANY(sv))->xpvcuru_fmdepth;
+#else
        : &((XPVCV*)SvANY(sv))->xpv_cur_u.xpvcuru_fmdepth;
+#endif
 }
 #if defined(__GNUC__) && !defined(PERL_GCC_BRACE_GROUPS_FORBIDDEN)
 #  define CvDEPTH(sv) (*({const CV *const _cvdepth = (const CV *)sv; \
index 7624cac..ec532ed 100644 (file)
@@ -484,8 +484,7 @@ Machine code size reductions, already made to the DLLs of XS modules in Perl
 5.17.2, have now been extended to the perl DLL itself.
 
 Building with VC++ 6.0 was inadvertently broken in Perl 5.17.2 but has now been
-fixed again.  XXX Actually, it's now been broken again, so ensure that it gets
-fixed once more before release, or remove this comment!
+fixed again.
 
 =item VMS
 
diff --git a/sv.h b/sv.h
index b69979f..1c0a0f1 100644 (file)
--- a/sv.h
+++ b/sv.h
@@ -412,6 +412,20 @@ perform the upgrade if necessary.  See C<svtype>.
 /* pad name vars only */
 #define SVpad_STATE    0x80000000  /* pad name is a "state" var */
 
+/* MSVC6 generates "error C2099: initializer is not a constant" when
+ * initializing bodies_by_type in sv.c. Workaround the compiler bug by
+ * using an anonymous union, but only for MSVC6 since that isn't C89.
+ */
+#if defined(_MSC_VER) && _MSC_VER < 1300
+#define _XPV_HEAD                                                      \
+    HV*                xmg_stash;      /* class package */                     \
+    union _xmgu        xmg_u;                                                  \
+    union {                                                            \
+       STRLEN  xpvcuru_cur;    /* length of svu_pv as a C string */    \
+       I32     xpvcuru_fmdepth;                                        \
+    };                                                                 \
+    STRLEN     xpv_len         /* allocated size */
+#else
 #define _XPV_HEAD                                                      \
     HV*                xmg_stash;      /* class package */                     \
     union _xmgu        xmg_u;                                                  \
@@ -420,8 +434,13 @@ perform the upgrade if necessary.  See C<svtype>.
        I32     xpvcuru_fmdepth;                                        \
     }          xpv_cur_u;                                              \
     STRLEN     xpv_len         /* allocated size */
+#endif
 
+#if defined(_MSC_VER) && _MSC_VER < 1300
+#define xpv_cur        xpvcuru_cur
+#else
 #define xpv_cur        xpv_cur_u.xpvcuru_cur
+#endif
 
 union _xnvu {
     NV     xnv_nv;             /* numeric value, if any */