I don't know how SWIG handles this, or even if it handles "output parameters" correctly, but as a first shot, make sure $response is already a string of size $respsize before calling the function, and check the output of sendMessage (looks like a status code).
my $response = " " x 100; # 100 spaces + 0 char
my $respsize = length $response; # 100
my $status = $c->sendMsg("hello",$response,$respsize);
print "status = $status, response is '$response'\n";
| [reply] [d/l] |
I don't know SWIG at all - perhaps there are others here that can offer advice. But on most of the forums (fora ?) that I peruse there's not much advice forthcoming wrt SWIG - though there are plenty that are willing and able to offer good advice wrt Inline::C and Inline::CPP.
The function prototype would suggest that the task is trivial with Inline::C (or Inline::CPP) - so maybe try that path if you don't get a helpful answer to the question that you actually asked.
My hunch is that something like '$ret = sendMsg("hello", $response, $respsize);' ought to work if $respsize is set to the appropriate value .... but I'm really going out on a limb ... and a very thin one at that ... in fact I can feel it breaking away as I'm typing ...
Cheers, Rob | [reply] |