Help with xs: converting I32 to int ?

Ask a Question related to PERL Modules, Design and Development.

  1. #1

    Default Help with xs: converting I32 to int ?

    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 [url]http://www.pjb.com.au[/url]
    Pasaré, pasarémos dice el agua y canta la verdad contra la piedra
    -- Pablo Neruda
    Peter Billam Guest

  2. Similar Questions and Discussions

    1. Converting into PDF bug...
      I am trying to convert a file into PDF (a 20 page one) and I keep getting an error message: "unable to convert file" at the end. It seems to be...
    2. converting PHP to jsp
      does anyone know if a website that has been programmed using PHP can be converted to a site that uses jsp?
    3. Converting .PDF into CF
      Is there a way using Coldfusion MX to convert a .PDF into a web page? I know with the new CF7, there is a cfdocument tag, but I only have CF6.
    4. Converting From PHP
      I'm converting a site from PHP to ColdFusion and need to find a compatible feature as __LINE__ magic variable in php to report the line number...
    5. Converting to PDF
      How do you install Acrobat distiller printer? It does not appear in my printers in XP. Can you give me the EASIEST steps to set up my computer to...
  3. #2

    Default Re: Help with xs: converting I32 to int ?


    "Peter Billam" <peter@pjb.dpiwe.tas.gov.au> wrote in message
    news:slrne3jate.cu5.peter@localhost.localdomain...
    > 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



    Sisyphus Guest

  4. #3

    Default Re: Help with xs: converting I32 to int ?


    "Peter Billam" <peter@pjb.dpiwe.tas.gov.au>
    > 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


    Sisyphus Guest

  5. #4

    Default Re: Help with xs: converting I32 to int ?

    On 2006-04-10, Sisyphus <sisyphus1@nomail.afraid.org> wrote:
    > > 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 [url]http://www.pjb.com.au[/url]
    Pasaré, pasarémos dice el agua y canta la verdad contra la piedra
    -- Pablo Neruda
    Peter Billam Guest

  6. #5

    Default Re: Help with xs: converting I32 to int ?


    "Peter Billam" <peter@pjb.dpiwe.tas.gov.au> wrote in message
    ..
    ..
    > > 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


    Sisyphus Guest

  7. #6

    Default Re: Help with xs: converting I32 to int ?

    On 2006-04-11, Sisyphus <sisyphus1@nomail.afraid.org> wrote:
    > 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 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 [url]http://www.pjb.com.au[/url]
    Pasaré, pasarémos dice el agua y canta la verdad contra la piedra
    -- Pablo Neruda
    Peter Billam Guest

  8. #7

    Default Re: Help with xs: converting I32 to int ?


    "Peter Billam" <peter@pjb.dpiwe.tas.gov.au> wrote in message
    news:slrne3m44i.n18.peter@localhost.localdomain...
    > On 2006-04-11, Sisyphus <sisyphus1@nomail.afraid.org> wrote:
    > > 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 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.
    >
    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


    Sisyphus Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139