lizmat This channel is intended for people just starting with the Raku Programming Language (raku.org). Logs are available at irclogs.raku.org/raku-beginner/live.html
paurq Hi! I'm trying to call C memset using NativeCall, but i'm having issues making it portable for linux and windows. From reading the docs i thought this should work everywhere: 21:10
sub memset(Pointer $str, int32 $c, size_t $n) returns Pointer is native {*}
But that only works on linux, to make it work on windows i have to use this:
sub memset(Pointer $str, int32 $c, size_t $n) returns Pointer is native('ucrtbase') {*}
Am I missing something? or is there a way to select one version or the other depending on the OS?
gfldex my &memset = %*KERNEL ~~ /win32/ ?? sub (Pointer $str, int32 $c, size_t $n) returns Pointer is native('ucrtbase') {*} !! sub (Pointer $str, int32 $c, size_t $n) returns Pointer is native {*}; 21:14
paurq: ^^^ something along those lines should work
and yes, C-land is not overly portable 21:15
paurq thanks! It works with a couple changes: 21:26
my &memset = $*KERNEL ~~ /win32/
        ?? sub (Pointer $str, int32 $c, size_t $n) returns Pointer is symbol('memset') is native('ucrtbase') {*}
        !! sub (Pointer $str, int32 $c, size_t $n) returns Pointer is symbol('memset') is native {*};
jgaz How do I slurp a binary file with `my $data = slurp($file_name)` or similar? 23:17
NM, I think I have it: `slurp($file_name, :bin)` if I'm not mistaken. 23:22
guifa jgaz: yup, that works 23:49