[Note: I originally reported this as a bug against perl 5.8.8. (See
http://rt.perl.org/rt3/Public/Bug/Display.html?id=46431), but have been
advised that the XS stuff has been removed from the core (so that's why
I didn't find it in the 5.9.x source :-)). I have checked that the bug
is still present in Extutils-ParseXS 2.18, but the problematic line is
now in ParseXS.pm (around 1117) instead of xsubpp]
Consider the following XS code:
void
judy1_thaw(unsigned long set, char *str, unsigned long length(str))
CODE:
Pvoid_t s1 = (Pvoid_t)set;
This gets translated into into:
XS(XS_Bit__Vector__Judy_judy1_thaw); /* prototype to pass
-Wmissing-prototypes */
XS(XS_Bit__Vector__Judy_judy1_thaw)
{
dXSARGS;
if (items != 2)
Perl_croak(aTHX_ "Usage: Bit::Vector::Judy::judy1_thaw(set, str)");
PERL_UNUSED_VAR(cv); /* -W */
{
STRLEN STRLEN_length_of_str;
unsigned long XSauto_length_of_str;
unsigned long set = (unsigned long)SvUV(ST(0));
char * str = (char *)SvPV(ST(1), STRLEN_length_of_str);
XSauto_length_of_str = STRLEN_length_of_str;#line 361 "Judy.xs"
Pvoid_t s1 = (Pvoid_t)set;
The preprocessor directive '#line 361 "Judy.xs"' gets tacked at the end
of the previous line, which gcc doesn't like:
Judy.c: In function ‘XS_Bit__Vector__Judy_judy1_thaw’:
Judy.c:599: error: stray ‘#’ in program
Adding a newline fixes the problem:
--- lib/ExtUtils/xsubpp.orig 2005-04-21 18:03:46.000000000 +0200
+++ lib/ExtUtils/xsubpp 2007-10-14 21:45:36.000000000 +0200
@@ -430,7 +430,7 @@
print "\tSTRLEN\tSTRLEN_length_of_$2;\n";
$lengthof{$2} = $name;
# $islengthof{$name} = $1;
- $deferred .= "\n\tXSauto_length_of_$2 = STRLEN_length_of_$2;";
+ $deferred .= "\n\tXSauto_length_of_$2 = STRLEN_length_of_$2;\n";
}
# check for optional initialisation code