Subject: | Reduce compiler warnings |
Hi,
In 5.8, C files created by ParseXS produces a number of warnings, so I
have written a patch to fix it.
* If arguments of a xsub is "(...)", "cv" "items" are likely to be
unused.
* The prototype of the third argument of newXS() is now (5.10.0) "const
char*", whareas that of 5.8 is "char*". Therefore, to reduce warnings,
this patch uses __FILE__ instead of the "file" variable.
In addition, to make matters consistent, ParseXS should not see $]
($PERL_VERSION), so PL_unitcheck is checked in C files instead of in
ParseXS.
Regards,
--
Goro Fuji (gfx) GFUJI at CPAN.org
Subject: | ParseXS.patch |
--- ParseXS.pm.orig 2008-08-07 12:18:01.000000000 +0900
+++ ParseXS.pm 2009-03-07 12:54:25.974798400 +0900
@@ -314,7 +314,7 @@
EOF
- print <<"EOF";
+ print <<'EOF';
#ifndef PERL_ARGS_ASSERT_CROAK_XS_USAGE
#define PERL_ARGS_ASSERT_CROAK_XS_USAGE assert(cv); assert(params)
@@ -345,13 +345,9 @@
}
#undef PERL_ARGS_ASSERT_CROAK_XS_USAGE
-#ifdef PERL_IMPLICIT_CONTEXT
#define croak_xs_usage(a,b) S_croak_xs_usage(aTHX_ a,b)
-#else
-#define croak_xs_usage S_croak_xs_usage
-#endif
-#endif
+#endif /* PERL_ARGS_ASSERT_CROAK_XS_USAGE */
EOF
@@ -646,9 +642,10 @@
# croak_xs_usage(cv, "$report_args");
EOF
} else {
- # cv likely to be unused
+ # cv and items likely to be unused
print Q(<<"EOF");
# PERL_UNUSED_VAR(cv); /* -W */
+# PERL_UNUSED_VAR(items); /* -W */
EOF
}
@@ -903,7 +900,7 @@
unless defined $XsubAliases{$pname} ;
while ( ($name, $value) = each %XsubAliases) {
push(@InitFileCode, Q(<<"EOF"));
-# cv = newXS(\"$name\", XS_$Full_func_name, file);
+# cv = newXS(\"$name\", XS_$Full_func_name, __FILE__);
# XSANY.any_i32 = $value ;
EOF
push(@InitFileCode, Q(<<"EOF")) if $proto;
@@ -913,7 +910,7 @@
}
elsif (@Attributes) {
push(@InitFileCode, Q(<<"EOF"));
-# cv = newXS(\"$pname\", XS_$Full_func_name, file);
+# cv = newXS(\"$pname\", XS_$Full_func_name, __FILE__);
# apply_attrs_string("$Package", cv, "@Attributes", 0);
EOF
}
@@ -921,7 +918,7 @@
while ( ($name, $value) = each %Interfaces) {
$name = "$Package\::$name" unless $name =~ /::/;
push(@InitFileCode, Q(<<"EOF"));
-# cv = newXS(\"$name\", XS_$Full_func_name, file);
+# cv = newXS(\"$name\", XS_$Full_func_name, __FILE__);
# $interface_macro_set(cv,$value) ;
EOF
push(@InitFileCode, Q(<<"EOF")) if $proto;
@@ -931,7 +928,7 @@
}
else {
push(@InitFileCode,
- " ${newXS}(\"$pname\", XS_$Full_func_name, file$proto);\n");
+ " ${newXS}(\"$pname\", XS_$Full_func_name, __FILE__$proto);\n");
}
}
@@ -950,7 +947,7 @@
/* Making a sub named "${Package}::()" allows the package */
/* to be findable via fetchmethod(), and causes */
/* overload::Overloaded("${Package}") to return true. */
- newXS("${Package}::()", XS_${Packid}_nil, file$proto);
+ newXS("${Package}::()", XS_${Packid}_nil, __FILE__$proto);
MAKE_FETCHMETHOD_WORK
}
@@ -976,12 +973,6 @@
##endif
EOF
- #-Wall: if there is no $Full_func_name there are no xsubs in this .xs
- #so `file' is unused
- print Q(<<"EOF") if $Full_func_name;
-# const char* file = __FILE__;
-EOF
-
print Q("#\n");
print Q(<<"EOF");
@@ -994,9 +985,10 @@
#
EOF
- print Q(<<"EOF") if defined $XsubAliases or defined $Interfaces ;
+ print Q(<<'EOF') if defined $XsubAliases or defined $Interfaces ;
# {
# CV * cv ;
+# PERL_UNUSED_VAR(cv); /* -W */
#
EOF
@@ -1026,12 +1018,12 @@
print "\n /* End of Initialisation Section */\n\n" ;
}
- if ($] >= 5.009) {
- print <<'EOF';
- if (PL_unitcheckav)
- call_list(PL_scopestack_ix, PL_unitcheckav);
+ print Q(<<'EOF');
+##if PERL_REVISION == 5 && PERL_VERSION >= 9 /* >= 5.9.0 */
+# if (PL_unitcheckav)
+# call_list(PL_scopestack_ix, PL_unitcheckav);
+##endif
EOF
- }
print Q(<<"EOF");
# XSRETURN_YES;
@@ -1352,7 +1344,7 @@
$Overload = 1 unless $Overload;
my $overload = "$Package\::(".$1 ;
push(@InitFileCode,
- " newXS(\"$overload\", XS_$Full_func_name, file$proto);\n");
+ " newXS(\"$overload\", XS_$Full_func_name, __FILE__$proto);\n");
}
}
}