This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Using #ifdef inside macro arguments confuses VC++ 2008
authorTony Cook <tony@develop-help.com>
Sat, 20 Oct 2018 23:40:46 +0000 (10:40 +1100)
committerTony Cook <tony@develop-help.com>
Sat, 20 Oct 2018 23:40:46 +0000 (10:40 +1100)
This caused compilation errors for me when building with the
Windows 7 SDK packaged version of MSVC.

regcomp.c

index b9a5b5c..105059f 100644 (file)
--- a/regcomp.c
+++ b/regcomp.c
@@ -965,6 +965,7 @@ static const scan_data_t zero_scan_data = {
 #define Set_Node_Offset_Length(node,offset,len)
 #define ProgLen(ri) ri->u.proglen
 #define SetProgLen(ri,x) ri->u.proglen = x
+#define Track_Code(code)
 #else
 #define ProgLen(ri) ri->u.offsets[0]
 #define SetProgLen(ri,x) ri->u.offsets[0] = x
@@ -1007,6 +1008,8 @@ static const scan_data_t zero_scan_data = {
     Set_Node_Offset_To_R(REGNODE_OFFSET(node), (offset));      \
     Set_Node_Length_To_R(REGNODE_OFFSET(node), (len)); \
 } STMT_END
+
+#define Track_Code(code) STMT_START { code } STMT_END
 #endif
 
 #if PERL_ENABLE_EXPERIMENTAL_REGEX_OPTIMISATIONS
@@ -3603,9 +3606,7 @@ S_make_trie(pTHX_ RExC_state_t *pRExC_state, regnode *startbranch,
                 optimisation.
              */
             while( optimize < jumper ) {
-#ifdef RE_TRACK_PATTERN_OFFSETS
-                mjd_nodelen += Node_Length((optimize));
-#endif
+                Track_Code( mjd_nodelen += Node_Length((optimize)); );
                 OP( optimize ) = OPTIMIZED;
                 Set_Node_Offset_Length(optimize, 0, 0);
                 optimize++;