Subject: | Pre-5.8 C syntax bug |
Problem
-------
C syntax problem compiling IO.xs w/ perl 5.6.1 (and probably any perl <5.8).
Workaround
----------
Add {} to put definition of "pos" at head of block. Scope isn't an issue.
{417} % diff -c IO.xs*
*** IO.xs Tue Jun 13 15:03:57 2006
--- IO.xs.OLD Tue Jun 13 15:03:23 2006
***************
*** 135,141 ****
#ifdef PerlIO
ST(0) = sv_newmortal();
#if PERL_VERSION < 8
- {
Fpos_t pos;
if (PerlIO_getpos(handle, &pos) != 0) {
ST(0) = &PL_sv_undef;
--- 135,140 ----
***************
*** 143,149 ****
else {
sv_setpvn(ST(0), (char *)&pos, sizeof(Fpos_t));
}
- }
#else
if (PerlIO_getpos(handle, ST(0)) != 0) {
ST(0) = &PL_sv_undef;
--- 142,147 ----
{418} %
Example of problem
------------------
{392} % perl Makefile.PL
Checking if your kit is complete...
Looks good
Writing Makefile for IO
{393} % make
cp IO/Poll.pm blib/lib/IO/Poll.pm
cp IO/Socket/INET.pm blib/lib/IO/Socket/INET.pm
cp IO/Socket.pm blib/lib/IO/Socket.pm
cp IO/Select.pm blib/lib/IO/Select.pm
cp IO/Pipe.pm blib/lib/IO/Pipe.pm
cp IO/Handle.pm blib/lib/IO/Handle.pm
cp IO/Socket/UNIX.pm blib/lib/IO/Socket/UNIX.pm
cp IO/File.pm blib/lib/IO/File.pm
cp IO.pm blib/lib/IO.pm
cp IO/Dir.pm blib/lib/IO/Dir.pm
cp IO/Seekable.pm blib/lib/IO/Seekable.pm
/usr/home/deltasq/usr/local/bin/perl
-I/usr/local/lib/perl5/5.6.1/i386-freebsd -I/usr/local/lib/perl5/5.6.1
/usr/local/lib/perl5/5.6.1/ExtUtils/xsubpp -typemap
/usr/local/lib/perl5/5.6.1/ExtUtils/typemap IO.xs > IO.xsc && mv IO.xsc IO.c
cc -c -fno-strict-aliasing -I/usr/local/include -O
-DVERSION=\"1.23\" -DXS_VERSION=\"1.23\" -DPIC -fpic
-I/usr/local/lib/perl5/5.6.1/i386-freebsd/CORE IO.c
IO.xs: In function `XS_IO__Seekable_getpos':
IO.xs:138: syntax error before `pos'
IO.xs:139: `pos' undeclared (first use in this function)
IO.xs:139: (Each undeclared identifier is reported only once
IO.xs:139: for each function it appears in.)
*** Error code 1
Stop in /usr/home/deltasq/tmp/x.done/IO-1.2301/IO-1.2301.
{394} %
Environment in which problem occurred
-------------------------------------
{396} % uname -a
FreeBSD deltasquare.com 4.7-RELEASE-p28 FreeBSD 4.7-RELEASE-p28 #40: Fri
Mar 11 14:16:49 MST 2005 root@fc2:/usr/src/sys/compile/VKERN i386
{397} % perl -V
Summary of my perl5 (revision 5.0 version 6 subversion 1) configuration:
Platform:
osname=freebsd, osvers=4.4-release, archname=i386-freebsd
uname='freebsd fc 4.4-release freebsd 4.4-release #0: wed dec 12
14:53:54 mst 2001 root@fc:usrsrcsyscompilevkern i386 '
config_args=''
hint=recommended, useposix=true, d_sigaction=define
usethreads=undef use5005threads=undef useithreads=undef
usemultiplicity=undef
useperlio=undef d_sfio=undef uselargefiles=define usesocks=undef
use64bitint=undef use64bitall=undef uselongdouble=undef
Compiler:
cc='cc', ccflags ='-fno-strict-aliasing -I/usr/local/include',
optimize='-O',
cppflags='-fno-strict-aliasing -I/usr/local/include'
ccversion='', gccversion='2.95.2 19991024 (release)', gccosandvers=''
intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234
d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12
ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t',
lseeksize=8
alignbytes=4, usemymalloc=n, prototype=define
Linker and Libraries:
ld='cc', ldflags ='-Wl,-E -L/usr/local/lib'
libpth=/usr/lib /usr/local/lib
libs=-lgdbm -lm -lc -lcrypt -liconv -lutil
perllibs=-lm -lc -lcrypt -liconv -lutil
libc=, so=so, useshrplib=false, libperl=libperl.a
Dynamic Linking:
dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags=' '
cccdlflags='-DPIC -fpic', lddlflags='-shared -L/usr/local/lib'
Characteristics of this binary (from libperl):
Compile-time options: USE_LARGE_FILES
Built under freebsd
Compiled at Jan 10 2002 11:56:19
@INC:
/usr/local/lib/perl5/5.6.1/i386-freebsd
/usr/local/lib/perl5/5.6.1
/usr/local/lib/perl5/site_perl/5.6.1/i386-freebsd
/usr/local/lib/perl5/site_perl/5.6.1
/usr/local/lib/perl5/site_perl
/usr/local/lib/perl5/5.00503
/usr/local/lib/site_perl
.
{398} %
--
Scott Leadley <leadley@deltasquare.com>