Embedded Perl sprintf (symbol?) problem.

Discussion in 'Perl Misc' started by R. Cheung, Feb 2, 2004.

  1. R. Cheung

    R. Cheung Guest

    I have a problem using sprintf in my embedded Perl interpreter. E.g.

    $decVal = 1234;
    $str = sprintf( "Result is %d, 0x%x", $decVal, $decVal );

    $str comes back containing rubbish like "Result is 17 0x11". It seems
    that sprintf can pick up the 1st parameter (the format string) but
    picks up completely wrong parameters subsequently. The interpreter
    seems to work fine when doing strictly Perl stuff (e.g. matching,
    substituting, etc.). I'm wondering if this is a symbol clash problem.
    I'm working in a Win2000 environment, embedding Perl in a Visual C++
    application. Could it be that it's picking up sprintf from the VC++
    library instead of Perl's own, or something like that? Does anyone
    have a solution to this problem? Thanks.
    R. Cheung, Feb 2, 2004
    #1
    1. Advertising

  2. R. Cheung

    Sisyphus Guest

    R. Cheung wrote:
    > I have a problem using sprintf in my embedded Perl interpreter. E.g.
    >
    > $decVal = 1234;
    > $str = sprintf( "Result is %d, 0x%x", $decVal, $decVal );
    >
    > $str comes back containing rubbish like "Result is 17 0x11". It seems
    > that sprintf can pick up the 1st parameter (the format string) but
    > picks up completely wrong parameters subsequently. The interpreter
    > seems to work fine when doing strictly Perl stuff (e.g. matching,
    > substituting, etc.). I'm wondering if this is a symbol clash problem.
    > I'm working in a Win2000 environment, embedding Perl in a Visual C++
    > application. Could it be that it's picking up sprintf from the VC++
    > library instead of Perl's own, or something like that? Does anyone
    > have a solution to this problem? Thanks.


    Can you post some simple code that demonstrates the problem (and will
    also compile) ?

    Cheers,
    Rob

    --
    To reply by email u have to take out the u in kalinaubears.
    Sisyphus, Feb 3, 2004
    #2
    1. Advertising

  3. R. Cheung

    gnari Guest

    "Sisyphus" <> wrote in message
    news:401f3cc6$0$1746$...
    > R. Cheung wrote:
    > > I have a problem using sprintf in my embedded Perl interpreter. E.g.
    > >
    > > $decVal = 1234;
    > > $str = sprintf( "Result is %d, 0x%x", $decVal, $decVal );
    > >
    > > $str comes back containing rubbish like "Result is 17 0x11". It seems
    > > ...


    > Can you post some simple code that demonstrates the problem (and will
    > also compile) ?


    I think the point was that his code works under normal perl, but not with
    embedded perl.

    Still, the idea is valid. the OP should try to make a minimal program w/
    embedded perl, and see if the problem persists.

    gnari
    gnari, Feb 3, 2004
    #3
  4. R. Cheung

    Sisyphus Guest

    gnari wrote:

    > Still, the idea is valid. the OP should try to make a minimal program w/
    > embedded perl, and see if the problem persists.


    I'd stop short of saying that it's mandatory to provide some compilable
    demonstration code - but I, for one, am certainly *not* going to think
    about the problem if I have to create test code from scratch. I imagine
    that others share the same attitude.

    Otoh, if there was some code supplied I would certainly look at it, and
    play with it, and try to determine the cause of the problem .... not to
    say that I'd succeed, of course :)

    It's just that it's simply in the best interests of the OP to follow the
    posting guidelines and supply such code. That's all I was trying to get
    at :)

    Cheers,
    Rob


    --
    To reply by email u have to take out the u in kalinaubears.
    Sisyphus, Feb 3, 2004
    #4
  5. R. Cheung

    gnari Guest

    "Sisyphus" <> wrote in message
    news:401f9d76$0$1734$...

    [snipped discussion about lack of embedded perl example code]

    >
    > It's just that it's simply in the best interests of the OP to follow the
    > posting guidelines and supply such code. That's all I was trying to get
    > at :)


    no quarrel, but in this case, the OP would probably have to post
    c code, and someone is sure to complain about that :)

    gnari
    gnari, Feb 3, 2004
    #5
  6. R. Cheung

    Sisyphus Guest

    gnari wrote:

    >
    > no quarrel, but in this case, the OP would probably have to post
    > c code, and someone is sure to complain about that :)
    >


    (That wouldn't stop *me* from posting code :)

    I hadn't really considered that aspect. Such a complaint could only be
    valid if 'perlembed' issues are OT here - which, admittedly, may well be
    the case (and a pity, imho).

    I see there's an 'embperl' mailing list at http://lists.perl.org.
    Perhaps the OP should direct his question there.

    Cheers,
    Rob

    --
    To reply by email u have to take out the u in kalinaubears.
    Sisyphus, Feb 3, 2004
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. baumann@pan
    Replies:
    1
    Views:
    730
    Richard Bos
    Apr 15, 2005
  2. Toki Toki
    Replies:
    7
    Views:
    147
    Robert Klemme
    Apr 30, 2008
  3. Song Ma
    Replies:
    2
    Views:
    220
    Charles Oliver Nutter
    Jul 20, 2008
  4. Aphor
    Replies:
    0
    Views:
    83
    Aphor
    Jul 27, 2003
  5. Replies:
    6
    Views:
    1,726
Loading...

Share This Page