Help with xs: converting I32 to int ?
by Peter Billam » Tue, 11 Apr 2006 08:49:54 GMT
Hi. <xs newbie warning=on> Compiling my Math-WalshTransform-1.11 on a
Fedora5 with gcc 4.1.0 gives me (amongst other stuff which I can fix):
In file included from WalshTransform.xs:7:
ppport.h:231:1: warning: "PERL_UNUSED_DECL" redefined
In file included from WalshTransform.xs:5:
/usr/lib/perl5/5.8.8/i386-linux-thread-multi/CORE/perl.h:163:1:
warning: this is the location of the previous definition
WalshTransform.xs: In function 'XS_Math__WalshTransform_xs_fht':
WalshTransform.xs:50: warning: format '%d' expects type 'int',
but argument 4 has type 'I32'
WalshTransform.xs: In function 'XS_Math__WalshTransform_xs_fhtinv':
WalshTransform.xs:90: warning: format '%d' expects type 'int',
but argument 4 has type 'I32'
Now the PERL_UNUSED_DECL bit comes from a
#ifdef __cplusplus
extern "C" {
#endif
#include "EXTERN.h"
#include "perl.h"
#include "XSUB.h"
#include "ppport.h"
#include "math.h"
#ifdef __cplusplus
}
#endif
incantation at the beginning. Should I change this bit ?
The lines 50 and 90 are like
fprintf (stderr, "fhtinv: n should be a power of 2, but was %d\n", items);
How should I convert my I32 items builtin into an int ?
Regards, Peter
--
AUS/TAS/DPIWE/CIT/Servers hbt/lnd/l8 6233 3061 http://www.**--****.com/
Pasar? pasaros dice el agua y canta la verdad contra la piedra
-- Pablo Neruda
Re: Help with xs: converting I32 to int ?
by Sisyphus » Tue, 11 Apr 2006 14:33:04 GMT
.
.
items);
Not sure - '%d' is quite happy to accept an I32 for me. Does casting to an
'int' fix the problem :
fprintf (stderr, "fhtinv: n should be a power of 2, but was %d\n",
(int)items);
Cheers,
Rob
Re: Help with xs: converting I32 to int ?
by Sisyphus » Tue, 11 Apr 2006 15:22:52 GMT
"Peter Billam" < XXXX@XXXXX.COM >
.
.
Sorry - skipped this bit in my other reply. It's hard to answer -
search.cpan.org is still showing only version 1.10 (my mirror, at least) so
I can't get at a look at the actual ppport.h you've got.
There's a good chance the redefinition won't matter - but I doubt that it
should be happening. I would think the fact that PERL_UNUSED_DECL was
defined in perl.h should have been detected, and the definition omitted from
the generated ppport.h .... but I'm not really an expert on what ppport.h
should and should not do. (Come to think of it, I'm not an expert on
anything else, either.)
Do you need to include a ppport.h in the source ?
Cheers,
Rob
Re: Help with xs: converting I32 to int ?
by Peter Billam » Wed, 12 Apr 2006 05:57:47 GMT
Yes, it does fix the problem, thanks :-)
Ah, er, sorry, 1.11 is the _next_ release. But 1.10 behaves the same
for me under Fedora5 gcc4.1.0 ...
Well, apparently not; it compiles perfectly without #include "ppport.h",
so the question remains open of what ppport.h does, and when it's
needed.
Thanks for your help, expect Math::WalshTransform-1.11 sometime soon.
Regards, Peter
--
AUS/TAS/DPIW/CIT/Servers hbt/lnd/l8 6233 3061 http://www.**--****.com/
Pasar? pasaros dice el agua y canta la verdad contra la piedra
-- Pablo Neruda
Re: Help with xs: converting I32 to int ?
by Sisyphus » Wed, 12 Apr 2006 09:02:47 GMT
.
.
It's probably worth pointing out that if you ever declare dXSARGS in a
function, then 'items' becomes a keyword (within that function) and any
attempt to use 'items' as a variable name (within that function) will
produce fatal redefinition errors - error messages that don't really make it
clear just what the problem is. For that reason I always avoid using 'items'
as a variable name .... even though it's often the logical name to bestow
upon the variable.
Probably a good question for another post - unless someone else comes
forward here and answers it. I don't think I've ever seen any advocacy for
using it, or indeed any discussion about it. All I know is that it's a part
of a small percentage of source tarballs, and that its own documentation
says it's useful.
I've no doubt there are people perusing this list who know a good deal about
it, but if I were going to ask about the usage of ppport.h I'd probably post
to a higher volume list (like, say, PerlMonks) where there's a wider range
of respondents.
Cheers,
Rob
Re: Help with xs: converting I32 to int ?
by Peter Billam » Wed, 12 Apr 2006 10:12:39 GMT
I got my "items" from perldoc perlxs where it says:
XSUBs can have variable-length parameter lists by specifying an
ellipsis "(...)" in the parameter list. This use of the ellipsis
is similar to that found in ANSI C. The programmer is able to
determine the number of arguments passed to the XSUB by examining
the "items" variable which the xsubpp compiler supplies for all <==
XSUBs. By using this mechanism one can create an XSUB which
accepts a list of parameters of unknown length.
What's dXSARGS and when would I need to declare it ?
It's mentioned once in perldoc perlxstut, but not in perldoc perlxs.
Regards, Peter
--
AUS/TAS/DPIW/CIT/Servers hbt/lnd/l8 6233 3061 http://www.**--****.com/
Pasar? pasaros dice el agua y canta la verdad contra la piedra
-- Pablo Neruda
Re: Help with xs: converting I32 to int ?
by Sisyphus » Wed, 12 Apr 2006 12:57:43 GMT
Aaaahh .... sorry - I thought you had declared and were using a variable
named 'items' - but you're obviously not. In fact, you're using 'items' as
that very same reserved variable I was talking about. My mistake.
Cheers,
Rob
Similar Threads:
1.Convert int for string
2.KILL INT can not wake up $SIG{INT}
Hi list,
Anyone has such experience? KILL INT pid cannot wake up $SIG{INT} sub{}.
my code is like;
$SIG{INT} = sub {#load pm}
$SIG{ALRM} = sub {print "Driver $pm is going to sleep... bye.\n"; exit;};
the pm actually has a system call to execute something
sub xxx {
`perl xxx.pl`
}
but
my $tmp = kill "INT", $pid; ## it returns number of processes, eg: 1
cannot wake up the $SIG{INT} at all after $SIG{ALRM} has been executed.
does system call cause the problem?
Thanks.
3.Perl C, XS help
Hi,
I am trying port an Custom Perl module from one server to another. The
module uses C/XS and was built in 2001/2. I got the source and did
`perl Makefile.PL; make`. There was an error in one .c file:
...
store.c:592: error: 'my_perl' undeclared (first use in this function)
store.c:592: error: (Each undeclared identifier is reported only once
store.c:592: error: for each function it appears in.)
I solved that by adding
'static PerlInterpreter *my_perl;' near the top of the file.
After make distclean; perl Makefile, make and the same error with a
different file. This time however, once I added the static declaration
I got this error:
store.c:13: error: expected '=', ',', ';', 'asm' or '__attribute__'
before '*' token
It refers to the static declaration mentioned above.
I am a super newbie when it comes to C and I know this might be
straying OT but does anyone know how I can make this static declartion
in the correct way or perhaps point me to a list that might be able to
help?
Thanx,
Dp.
4.XS help
Hello All,
I'm trying to call C routine from Perl using XS but some how my 'make test'
is failing. Following are the steps I did :
file: hypotenuse.h
double hypotenuse(double x, double y); /* Func Declaration */
file: hypotenuse.c
/* Func Definition */
double hypotenuse(double x, double y)
{
return sqrt(x*x + y*y);
}
Steps :
1. h2xs -n Geometry -A -O -x -F '-I ../..' hypotenuse.h /created XS
components
2. cd Geometry // Went in the directory
3. cp ../hypotenuse.* . // Copied header and source files in Dir
4. Added Geometry.o and hypotenuse.o as objects in Makefile.pl
5. Perl Makefile.pl and make is ok
6. 'make test' is failing
Do someone have any idea where I'm going wrong? I did not read perl doc for
XS yet :(.
Error logs:
PERL_DL_NONLAZY=1 /usr/bin/perl "-MExtUtils::Command::MM" "-e"
"test_harness(0, 'blib/lib', 'blib/arch')" t/*.t
t/Geometry....NOK 1
# Failed test 'use Geometry;'
# in t/Geometry.t at line 9.
# Tried to use 'Geometry'.
# Error: Can't load
'/SES/rajni/claudio/rajni/myModule/Code/factorial/Geometry/blib/arch/auto/Ge
ometry/Geometry.so' for module Geometry:
/SES/rajni/claudio/rajni/myModule/Code/factorial/Geometry/blib/arch/auto/Geo
metry/Geometry.so: undefined symbol: hypotenuse at
/usr/lib/perl5/5.8.8/i586-linux-thread-multi/DynaLoader.pm line 230.
Thanks
Rajni
DISCLAIMER
==========
This e-mail may contain privileged and confidential information which is the property of Persistent Systems Ltd. It is intended only for the use of the individual or entity to which it is addressed. If you are not the intended recipient, you are not authorized to read, retain, copy, print, distribute or use this message. If you have received this communication in error, please notify the sender and delete all copies of this message. Persistent Systems Ltd. does not accept any liability for virus infected mails.
5.Help w/Class::Date Date.xs
6. Problem using more than 1 module in Windows (XS) - please help
7. Help - Perl, XS and global constructors
8. Why char** dynamic_string_array(int ROWS, int SIZE) doesn't work properly?