Embedded Perl sprintf (symbol?) problem.

R

R. Cheung

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

Sisyphus

R. Cheung said:
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
 
G

gnari

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
 
S

Sisyphus

gnari said:
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
 
G

gnari

[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
 
S

Sisyphus

gnari said:
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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,902
Latest member
Elena68X5

Latest Threads

Top