Click here to get back home

Help with xs: converting I32 to int ?

 HomeNewsGroups | Search | About
 comp.lang.perl.modules    Post an article   get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
Help with xs: converting I32 to int ? Peter Billam 04-09-2006
Get Chitika Premium
Posted by Peter Billam on April 9, 2006, 7:49 pm
Please log in for more thread options


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.pjb.com.au
Pasaré, pasarémos dice el agua y canta la verdad contra la piedra
-- Pablo Neruda

Posted by Sisyphus on April 10, 2006, 1:33 am
Please log in for more thread options



> 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'
>
.
.
> 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 ?
>

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




Posted by Sisyphus on April 10, 2006, 2:22 am
Please log in for more thread options




> 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
.
.
>
> 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 ?
>

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



Posted by Peter Billam on April 10, 2006, 4:57 pm
Please log in for more thread options


> > WalshTransform.xs:50: warning: format '%d' expects type 'int',
> > but argument 4 has type 'I32'
> 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);

Yes, it does fix the problem, thanks :-)

> > In file included from WalshTransform.xs:7:
> > ppport.h:231:1: warning: "PERL_UNUSED_DECL" redefined
> 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.
>
Ah, er, sorry, 1.11 is the _next_ release. But 1.10 behaves the same
for me under Fedora5 gcc4.1.0 ...

> I'm not really an expert on what ppport.h should and should not do.
> ... Do you need to include a ppport.h in the source ?

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.pjb.com.au
Pasaré, pasarémos dice el agua y canta la verdad contra la piedra
-- Pablo Neruda

Posted by Sisyphus on April 10, 2006, 8:02 pm
Please log in for more thread options



.
.
> > fprintf (stderr, "fhtinv: n should be a power of 2, but was %d\n",
> > (int)items);

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.

>
> > I'm not really an expert on what ppport.h should and should not do.
> > ... Do you need to include a ppport.h in the source ?
>
> 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.
>

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



Similar ThreadsPosted
Converting email December 21, 2004, 6:14 pm
Converting dates March 30, 2005, 5:22 am
converting phone numbers to alphabets July 7, 2004, 6:49 pm
Converting images with padding or cropping on left and right September 23, 2007, 8:55 am

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap