[Pdx-pm] Inline::C search.h 'Perl_push_scope'

Thomas Thompson vortix at hotmail.com
Tue May 12 14:33:38 PDT 2009


This is certainly not an Inline bug.  This is some interaction between perl.h and search.h.  I've actually found that while removing the #include <search.h> from the code will let the simple test run, it results in other problems.  It seems that if #include <search.h> is specified prior to #include <perl.h>, the code works.  If search.h is included after perl.h, there are issues.  This occurs whether I use Inline, swig, or just a simple compiled c program.

Which brings me to an Inline question.  If I look at the Inline output .xs file, it includes this at the top:
#include "EXTERN.h"
#include "perl.h"
#include "XSUB.h"
#include "INLINE.h"

Is there some configuration option that would allow me to end up with:
#include "search.h"
#include "EXTERN.h"
#include "perl.h"
#include "XSUB.h"
#include "INLINE.h"

I have looked over Inline documentation, but I can't seem to spot anything that does what I want.  I can add the include in the perl file with the c code, but then the search.h include occurs after the perl.h include and I run into my issue.

Thanks for the help :)

> From: jaleto at gmail.com
> Date: Tue, 12 May 2009 13:07:04 -0700
> Subject: Re: [Pdx-pm] Inline::C search.h 'Perl_push_scope'
> To: vortix at hotmail.com
> CC: pdx-pm-list at pm.org
> 
> Howdy,
> 
> If this *was* a bug with Inline, then you could report it here
> 
> http://rt.cpan.org/Public/Dist/Display.html?Name=Inline
> 
> Since this is a publicly archived list, if anyone googles for this
> error now, they will be pointed to this thread. If you really wanted
> to go the extra mile, you could provide a documentation patch to
> Inline which says something along the lines of "including certain
> header files multiple times may give you odd errors" or "don't
> re-include things that perl.h already does" or somesuch.  You would
> probably want to send this patch to SISYPHUS at cpan.org .
> 
> Cheers,
> 
> 
> 
> On Tue, May 12, 2009 at 11:56 AM, Thomas Thompson <vortix at hotmail.com> wrote:
> > The problem does not appear to be Inline::C related as I tried to do a
> > similar approach with swig and got the same compile error.
> >
> > After much digging, some promises of beer, and a few bribes I found that
> > perl.h apparently includes search.h.  I can remove the #include <search.h>
> > directive from my code and still have access to search.h functionality. This
> > also seems to clear up the compile error below.  This new code:
> >
> > #!/usr/intel/bin/perl -w
> >
> > use Inline C;
> > use strict;
> >
> > hello_inline();
> >
> > __END__
> > __C__
> > //#include <search.h>
> > #include <stdio.h>
> >
> > void hello_inline( ) {
> >     hcreate(10);   // search.h hash creation here, working happily
> >     printf( "Hello World. Best Regards from Inline\n" );
> > }
> >
> > Results in:
> > plxc1000> test_c3.pl
> > Hello World. Best Regards from Inline
> >
> > Somehow redeclaring the search.h include is causing a problem.  In any case,
> > this workaround will do what I need to do.  I appreciate any time you took
> > looking at this for me :)  Is there any followup I should do?  Is this a
> > bug, or was I not properly declaring/using search.h?  Should I report this
> > somewhere?  I'd like to try to be a useful member of the coding community
> > and make certain other people don't run into this issue.
> >
> > ________________________________
> > From: vortix at hotmail.com
> > To: jaleto at gmail.com
> > Date: Tue, 12 May 2009 11:48:41 -0500
> > CC: pdx-pm-list at pm.org
> > Subject: Re: [Pdx-pm] Inline::C search.h 'Perl_push_scope'
> >
> > Here's the output from the commands you mentioned.  I also included cc
> > --version as that seems to be the compiler mentioned in Perl -V.
> >
> > plxc1000> perl -V
> > Summary of my perl5 (revision 5 version 8 subversion 5) configuration:
> >   Platform:
> >     osname=linux, osvers=2.6.5-7.97-smp, archname=x86_64-linux
> >     uname='linux plxb0325 2.6.5-7.97-smp #1 smp fri jul 2 14:21:59 utc 2004
> > x86_64 x86_64 x86_64 gnulinux '
> >     config_args='-Uusemymalloc -Dprefix=/usr/intel/pkgs/perl/5.8.5
> > -Dcc=/usr/intel/pkgs/gcc/3.4.2/bin/gcc -Doptimize=none
> > -Dloclibpth=/usr/intel/00r1/lib -Dlocincpth=/usr/intel/00r1/include
> > -Duse64bitall -Uinstallusrbinperl -Duselargefiles
> > -Dperladmin=tmnguye3 at sedona.intel.com -Uinstallusrbinperl -des'
> >     hint=recommended, useposix=true, d_sigaction=define
> >     usethreads=undef use5005threads=undef useithreads=undef
> > usemultiplicity=undef
> >     useperlio=define d_sfio=undef uselargefiles=define usesocks=undef
> >     use64bitint=define use64bitall=define uselongdouble=undef
> >     usemymalloc=n, bincompat5005=undef
> >   Compiler:
> >     cc='/usr/intel/pkgs/gcc/3.4.2/bin/gcc', ccflags ='-fno-strict-aliasing
> > -pipe -I/usr/intel/00r1/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64',
> >     optimize=' ',
> >     cppflags='-fno-strict-aliasing -pipe -I/usr/intel/00r1/include'
> >     ccversion='', gccversion='3.4.2', gccosandvers=''
> >     intsize=4, longsize=8, ptrsize=8, doublesize=8, byteorder=12345678
> >     d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16
> >     ivtype='long', ivsize=8, nvtype='double', nvsize=8, Off_t='off_t',
> > lseeksize=8
> >     alignbytes=8, prototype=define
> >   Linker and Libraries:
> >     ld='/usr/intel/pkgs/gcc/3.4.2/bin/gcc', ldflags ='
> > -L/usr/intel/00r1/lib'
> >     libpth=/usr/intel/00r1/lib /lib /usr/lib /usr/local/lib
> >     libs=-lnsl -lgdbm -ldl -lm -lcrypt -lutil -lc
> >     perllibs=-lnsl -ldl -lm -lcrypt -lutil -lc
> >     libc=, so=so, useshrplib=false, libperl=libperl.a
> >     gnulibc_version='2.3.3'
> >   Dynamic Linking:
> >     dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-Wl,-E'
> >     cccdlflags='-fpic', lddlflags='-shared -L/usr/intel/00r1/lib'
> >
> >
> > Characteristics of this binary (from libperl):
> >   Compile-time options: USE_64_BIT_INT USE_64_BIT_ALL USE_LARGE_FILES
> >   Built under linux
> >   Compiled at Nov  1 2004 16:34:54
> >   %ENV:
> >
> > PERL5LIB="/usr/intel/pkgs/icc/9.0.025/lib:/nfs/pdx/disks/nehalem.pde.077/lib:/nfs/pdx/disks/nehalem.pde.077/instantclient_10_2/:/nfs/pdx/disks/nehalem.pde.077/mysql/5.0.27/lib:/nfs/pdx/disks/nehalem.pde.077/perl/lib/site_perl/5.8.5/x86_64-linux/Alien/SVN:/usr/ucblib:/usr/lib:/usr/intel/pkgs/freeTDS/0.61.2/lib:/nfs/pdx/disks/nehalem.pde.077/perl/lib/site_perl/5.8.5:/nfs/pdx/disks/nehalem.pde.077/perl/lib/5.8.5/:/nfs/pdx/disks/nehalem.pde.077/perl/Inline/lib/site_perl/5.8.5"
> >   @INC:
> >     /usr/intel/pkgs/icc/9.0.025/lib
> >     /nfs/pdx/disks/nehalem.pde.077/lib/5.8.5/x86_64-linux
> >     /nfs/pdx/disks/nehalem.pde.077/lib/5.8.5
> >     /nfs/pdx/disks/nehalem.pde.077/lib
> >     /nfs/pdx/disks/nehalem.pde.077/instantclient_10_2/
> >     /nfs/pdx/disks/nehalem.pde.077/mysql/5.0.27/lib
> >
> > /nfs/pdx/disks/nehalem.pde.077/perl/lib/site_perl/5.8.5/x86_64-linux/Alien/SVN
> >     /usr/ucblib
> >     /usr/lib
> >     /usr/intel/pkgs/freeTDS/0.61.2/lib
> >     /nfs/pdx/disks/nehalem.pde.077/perl/lib/site_perl/5.8.5/x86_64-linux
> >     /nfs/pdx/disks/nehalem.pde.077/perl/lib/site_perl/5.8.5
> >     /nfs/pdx/disks/nehalem.pde.077/perl/lib/5.8.5//x86_64-linux
> >     /nfs/pdx/disks/nehalem.pde.077/perl/lib/5.8.5/
> >
> > /nfs/pdx/disks/nehalem.pde.077/perl/Inline/lib/site_perl/5.8.5/x86_64-linux
> >     /nfs/pdx/disks/nehalem.pde.077/perl/Inline/lib/site_perl/5.8.5
> >     /usr/intel/pkgs/perl/5.8.5/lib/5.8.5/x86_64-linux
> >     /usr/intel/pkgs/perl/5.8.5/lib/5.8.5
> >     /usr/intel/pkgs/perl/5.8.5/lib/site_perl/5.8.5/x86_64-linux
> >     /usr/intel/pkgs/perl/5.8.5/lib/site_perl/5.8.5
> >     /usr/intel/pkgs/perl/5.8.5/lib/site_perl
> >
> > plxc1000> cc --version
> > cc (GCC) 3.3.3 (SuSE Linux)
> > Copyright (C) 2003 Free Software Foundation, Inc.
> > This is free software; see the source for copying conditions.  There is NO
> > warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
> >
> > plxc1000> gcc --version
> > gcc (GCC) 3.4.2
> > Copyright (C) 2004 Free Software Foundation, Inc.
> > This is free software; see the source for copying conditions.  There is NO
> > warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
> >
> > Inline is version: 0.44
> >
> > A Perl upgrade could potentially be quite painful, but if there's no obvious
> > fix for this issue I'm willing to give it a shot.  I find that getting the
> > compiler options/directives correct is pretty tough for us new guys :)
> >
> > Thanks!
> >
> >
> >> From: jaleto at gmail.com
> >> Date: Tue, 12 May 2009 00:26:41 -0700
> >> Subject: Re: [Pdx-pm] Inline::C search.h 'Perl_push_scope'
> >> To: vortix at hotmail.com
> >> CC: pdx-pm-list at pm.org
> >>
> >> Howdy,
> >>
> >> Providing the output of "perl -V" , "gcc --version" and the version of
> >> Inline would be useful. Also, Perl 5.8.3 is quite old, so upgrading to
> >> a more recent version of Perl and Inline may solve your issue without
> >> the need for exotic debugging, if that is possible.
> >>
> >> Cheers,
> >>
> >>
> >>
> >> 2009/5/11 Thomas Thompson <vortix at hotmail.com>:
> >> > Hi guys,
> >> >
> >> > This is my first post to this list.  I'm not an expert in Perl and
> >> > definitely a beginner with C.  I'm trying to rewrite a short section of
> >> > some
> >> > Perl code in C, but I've bumped into the following issue:
> >> >
> >> > #!/usr/bin/perl -w
> >> >
> >> > use Inline C;
> >> > use strict;
> >> >
> >> > hello_inline();
> >> >
> >> > __END__
> >> > __C__
> >> > #include <stdio.h>
> >> >
> >> > void hello_inline( ) {
> >> >         printf( "Hello World. Best Regards from Inline\n" );
> >> > }
> >> >
> >> > The above code works fine, and the output is:
> >> >
> >> > plxc1000> test_c3.pl
> >> > Hello World. Best Regards from Inline
> >> >
> >> > However, the following code (adding the search.h header file):
> >> >
> >> > #!/usr/bin/perl -w
> >> >
> >> > use Inline C;
> >> > use strict;
> >> >
> >> > hello_inline();
> >> >
> >> > __END__
> >> > __C__
> >> > #include <stdio.h>
> >> > #include <search.h>
> >> >
> >> > void hello_inline( ) {
> >> >         printf( "Hello World. Best Regards from Inline\n" );
> >> > }
> >> >
> >> > Results in this output:
> >> >
> >> > plxc1000> test_c3.pl
> >> > /usr/bin/perl /usr/lib/perl5/5.8.3/ExtUtils/xsubpp  -typemap
> >> > /usr/lib/perl5/5.8.3/ExtUtils/typemap   test_c3_pl_f52f.xs >
> >> > test_c3_pl_f52f.xsc && mv test_c3_pl_f52f.xsc test_c3_pl_f52f.c
> >> > cc -c  -I/nfs/pdx/disks/nehalem.pde.077/projects/rapttr/src -D_REENTRANT
> >> > -D_GNU_SOURCE -DTHREADS_HAVE_PIDS -fno-strict-aliasing
> >> > -D_LARGEFILE_SOURCE
> >> > -D_FILE_OFFSET_BITS=64 -O2 -fmessage-length=0 -Wall -Wall -pipe
> >> > -DVERSION=\"0.00\" -DXS_VERSION=\"0.00\" -fPIC
> >> > "-I/usr/lib/perl5/5.8.3/x86_64-linux-thread-multi/CORE"
> >> > test_c3_pl_f52f.c
> >> > In file included from test_c3_pl_f52f.xs:6:
> >> > /usr/include/search.h:66: error: `Perl_push_scope' redeclared as
> >> > different
> >> > kind of symbol
> >> > /usr/lib/perl5/5.8.3/x86_64-linux-thread-multi/CORE/proto.h:590: error:
> >> > previous declaration of `Perl_push_scope'
> >> > /usr/include/search.h:66: error: parse error before '(' token
> >> > make: *** [test_c3_pl_f52f.o] Error 1
> >> >
> >> > A problem was encountered while attempting to compile and install your
> >> > Inline
> >> > C code. The command that failed was:
> >> >   make > out.make 2>&1
> >> >
> >> > Looking through the search.h header file, I don't see any instance of
> >> > Perl_push_scope being redeclared, especially not on line 66 (which seems
> >> > to
> >> > be the middle of an enum type declaration).  I have not modified any of
> >> > these header files.  This is on SUSE LINUX Enterprise Server 9 (x86_64).
> >> >
> >> > Any ideas to help out a new guy? :)  Let me know if I missed information
> >> > I
> >> > should provide when asking this type of question and I'll make certain
> >> > to
> >> > make certain to provide everything you guys need in the future.  I
> >> > appreciate the help!
> >> >
> >> > Thomas
> >> >
> >> >
> >> > ________________________________
> >> > Insert movie times and more without leaving Hotmail®. See how.
> >> > _______________________________________________
> >> > Pdx-pm-list mailing list
> >> > Pdx-pm-list at pm.org
> >> > http://mail.pm.org/mailman/listinfo/pdx-pm-list
> >> >
> >>
> >>
> >>
> >> --
> >>
> >> Jonathan Leto
> >> jonathan at leto.net
> >> http://leto.net
> >
> > ________________________________
> > Insert movie times and more without leaving Hotmail®. See how.
> > ________________________________
> > Windows Live™: Keep your life in sync. Check it out.
> 
> 
> 
> -- 
> 
> Jonathan Leto
> jonathan at leto.net
> http://leto.net

_________________________________________________________________
Insert movie times and more without leaving Hotmail®.
http://windowslive.com/Tutorial/Hotmail/QuickAdd?ocid=TXT_TAGLM_WL_HM_Tutorial_QuickAdd1_052009
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.pm.org/pipermail/pdx-pm-list/attachments/20090512/a2b2e343/attachment-0001.html>


More information about the Pdx-pm-list mailing list