On Sun, Apr 3, 2016 at 1:26 PM, Timo Paulssen <t...@wakelift.de> wrote: > When you have a sub that's not "our", it will not show up in the > module's namespace. Since you export the sub, it'll be available without > LIBCIO:: before its name. > > I suggest you pass Str (the String type object) instead of 'libc' for > the native trait, as the symbol is pretty much guaranteed to already be > loaded in the program.
Okay, then, with that help this works: LIBCIO.pm6: unit module LIBCIO; use NativeCall; our sub fopen(Str, Str) returns Pointer is native(Str) is export(:fopen) { * } our sub fclose(Pointer) is native(Str) is export(:fclose) { * } I then successfully (so far) use them in a Perl 6 sub: # try NativeCall use lib '.'; use LIBCIO :fopen, :fclose; # get a file pointer my Str $mode = 'r'; my $fp = LIBCIO::fopen($ifil, $mode); # close the file fclose($fp); I don't see any example of any easier syntax in the "use LIBCIO" or "our sub fopen..." lines, but I thought one could do something like: use LIBCIO <fopen fclose>; If so, how are those subs then declared in LIBCIO? Thanks, Timo. Best regards, -Tom P.S. I plan to make a pull request adding some of this to the language docs in "Modules" and "NativeCall" as more examples.