I'm sorry for misreading your answer (not enough caffeine).

I tried what I understood from you response and... it works! Thanks a lot for helping me. For any other person out there the xs that made it work was (note that the substantial changes are in the respond function, the rest was just because there was no more need to use the derived class):

#ifdef __cplusplus extern "C" { #endif #include "EXTERN.h" #include "perl.h" #include "XSUB.h" #include "ppport.h" #ifdef __cplusplus } #endif #include <string> #include <libaiml/core.h> using std::string; using aiml::cCore; using aiml::AIMLError; MODULE = AI::AIML PACKAGE = AI::AIML cCore * cCore::new() void cCore::DESTROY() bool cCore::initialize(const char* file) void cCore::deinitialize() long cCore::get_error() const char* cCore::get_error_str(AIMLError error_num); const char* cCore::respond(const char* input, const char* username) CODE: string out; if (!THIS->respond(input, username, out)) XSRETURN_UNDEF; else RETVAL = out.c_str(); OUTPUT: RETVAL

I obviously also changed the typemap accordingly (cAiml -> cCore).

Don't know if you know what AIML is (you can google that), but if you do, you may understand my happiness when I read this:

PERL_DL_NONLAZY=1 /usr/bin/perl5.8.6 "-MExtUtils::Command::MM" "-e" "t +est_harness(0, 'blib/lib', 'blib/arch')" t/*.t t/AI-AIML....ok 3/4# Returned: Hello there. + t/AI-AIML....ok + All tests successful. Files=1, Tests=4, 8 wallclock secs ( 7.48 cusr + 0.16 csys = 7.64 C +PU)
(notice the "Returned", as an aswer to "hi") =] Thanks a lot.

In reply to Re^4: C++ strings, references and XS (char*) by v01d
in thread C++ strings, references and XS by v01d

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.