From f28d8eb1c114895944de593e05ba8271fe1b4fdf Mon Sep 17 00:00:00 2001 From: Steve Hay Date: Sat, 18 Aug 2012 00:33:53 +0100 Subject: [PATCH] Restore VC++ 6 build on Windows 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 | 4 ++++ pod/perldelta.pod | 3 +-- sv.h | 19 +++++++++++++++++++ 3 files changed, 24 insertions(+), 2 deletions(-) diff --git a/cv.h b/cv.h index e8cb162..cd722f3 100644 --- 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; \ diff --git a/pod/perldelta.pod b/pod/perldelta.pod index 7624cac..ec532ed 100644 --- a/pod/perldelta.pod +++ b/pod/perldelta.pod @@ -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 --- a/sv.h +++ b/sv.h @@ -412,6 +412,20 @@ perform the upgrade if necessary. See C. /* 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. 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 */ -- 2.7.4