I am able to access a C++ Dll using Win32::API module for class function whose return type is "Int" .
Same approach does not work fine with "Char" return type
My Test.cpp file
char __stdcall CDllTest::sum_char(char a, char b) { char c ; int temp; temp = (int)a + (int)b; c= (char)temp; printf("temp value %d\n",temp); printf("Afrer conversion%c\n",c); printf("%d,%d,%c\n",a,b,c); return c; }
nOte :return type for function sum_char is char
Perl File Test.pl
#!/usr/bin/perl -slw #use strict; #use warnings; use Win32; use Win32::API; use Win32::API::Callback; use Win32::API::Test; my $num; my $fun = Win32::API->new('Test.dll','char sum_char(char a,char b,char + c)') or die $^E; print "$fun\n"; my $character = chr(49); print "$character\n"; my $character1 = chr(50); print "$character1\n"; $num = $fun->Call($character,$character1); print "$num\n";
when I run the above perl scrip I get the folllowing error msg:
D:\strawberry\perl\bin>perl Test.pl Win32::API=HASH(0x3faa74) temp value 106 Afrer conversion j(o/p printf on C++ side) 53,53,j(o/p printf on C++ side) Use of uninitialized value $num in concatenation (.) or string at Test +.pl line 40.
Return value does not point to $num .
Is this probelm from Perl side
how do i handle data types that is returned for C++ class function in perl script

In reply to how to slove the "Use of uninitialized value in concatenation (.) or string at" by anupama

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.