I have a third-party C library that defines a structure similar to:
struct myStruct { int a; int b; char str1[32]; char str2[32]; };
And a function that takes a pointer to this structure and populates it. I need my own Perl6 call to provide this structure and then read the results.
So far, I have a framework defined in Perl6, like:
class myStruct is repr('CStruct') { has int32 $.a; has int32 $.b; has Str $.str1;
And a native call like:
sub fillStruct (myStruct) is native ('test_lib') {...}
my $ struct = myStruct.new ();
fillStruct ($ struct); # Gives a seg fault with any variation I've tried so far
How can I do this job?
source share