Hi,

On 25.05.2016 17:35, Fernando Santagata wrote:
> Hello,
> 
> Please excuse my naivety, I'm trying to use NativeCall to interface a
> Perl6 program with a C library and I have a problem mapping a char **
> argument.
> 
> The C function has this prototype:
> 
> void function(char **arg1, char **arg2);
> 
> I read that declaring a sub with Str rw parameters would do the trick:
> 
> sub test(Str $arg1 is rw, Str $arg2 is rw) is native('mylibrary') { * }
> 
> When I use the imported test function:
> 
> my Str ($arg1, $arg2);
> test($arg1, $arg2);
> say $arg1, $arg2;
> 
> what appears is just
> 
> (Str)(Str)

In my experience, "is rw" doesn't always work, and I have no idea when
or why.

In DBIish (a DB interface with backends for PostgreSQL, mysql, sqlite3
and Oracle, iirc) we tend to use CArray[Str] for the parameters, see for
example
https://github.com/perl6/DBIish/blob/master/lib/DBDish/Pg/Native.pm6#L83-92

Cheers,
Moritz

Reply via email to