I am trying to get this example of NativeCall
running:
use NativeCall;
class p_timespec is repr('CPointer') {
has uint32 $.tv_sec;
has long $.tv_nanosecs;
}
sub clock_gettime(uint32 $clock-id, p_timespec $tspec --> uint32) is native(Str) { * };
my p_timespec $this-time;
my $result = clock_gettime( 0, $this-time);
say "$result, $this-time";
It simply segfaults, which is what happens when you use pointers and you should not. In this case, it's probably due to the declaration of p_timespec
; I have actually declared it as a CPointer
, although the struct should be OK. However, from the segmentation fault I can't fathom what's really wrong. Can someone help?