On Oct 29, 2005, at 3:03 PM, Scott T. Hildreth wrote:
Try moving that declaration to the top of the for loop. I think this
is a gcc version problem. In other words variables have to be
declared
before code in the block. Maybe not, give it a try. :-)
Specifically, C89 requires all variables to be declared before any
code in a block, but C99 allows C++-style "declare anywhere"
variables. Newer versions of GCC started allowing this by default.
There are two ways to be safe, both illustrated here:
int
my_xsub (char * foo)
PREINIT:
/* safe place for variable declarations. */
int bar;
char * p;
CODE:
{
/* declare a new block to allow more variable
declarations.
* these may reference things that were initialized
from args. */
int baz = strlen (foo);
...
}
OUTPUT:
RETVAL
To see how this all works together, compare the XS input with the
generated C and you'll get the idea.
--
He's so good, you're gonna rock, and if you don't rock, it's your own
fault.
-- kk, describing the perks of having a very good drummer.