Most character or data pointers in C cannot be used just as such in perl. They will have to be converted to a SCALAR value

The nice thing about Inline::C is that it should take care of this, i.e. the necessary .xs (and .c) code doing the conversions is created behind the scenes - at least for simple types such as char*.

For example, the following function returning a char* is mapped to a normal scalar on the Perl side:

#!/usr/bin/perl use Inline C => Config => BUILD_NOISY => 1, CLEAN_AFTER_BUILD => 0; use Inline C => <<'END_OF_C_CODE'; char* GetImage() { char *data = "test-test-test"; return(data); } END_OF_C_CODE my $data = GetImage(); print "$data\n"; # "test-test-test"

(btw, the CLEAN_AFTER_BUILD => 0 option I've specified above is very useful when you want to look at the auto-generated XS/C wrapper code for debugging purposes)

So, if the data as returned by the OP's GetImage() function is in fact char*, things should just work fine in this regard. In other words, I suspect the problem lies elsewhere...


In reply to Re^2: Open CV problem by Anonyrnous Monk
in thread Open CV problem by russellp

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.