On 03/08/2017 02:58 PM, ToddAndMargo wrote:
Hi All,

With the help of the guys over on the char line, I wrote my first
inline code.  Yippee!!

I did not realize the name of the was was also the name
of the line line c call.  And I did not realize the
call really did want an initialized variable as its


    reference: man XDisplayName
    char *XDisplayName(char *string);
    sub display-name(Str:D $name) is native('X11') is
symbol("XDisplayName") { * }


        The XDisplayName() function returns the name of the display that
        would attempt to use. If a NULL string is specified,
XDisplayName() looks in the
        environment for the display and returns the display name that
XOpenDisplay() would
        attempt to use. This makes it easier to report to the user
precisely which display
        the program attempted to open when the initial connection
attempt failed.

use NativeCall;

sub XDisplayName(Str:D $name) is native('X11') returns Str { * };
my $Display;
my $NullStr; # Do not initialize this guy!
$Display = XDisplayName( $NullStr );
print "\$Display = <$Display>\n";

$ ./X11Display.pl6
$Display = <:0.0>

I also did not realize the Inline automatically fills
in the inline C code at "{ * }".  So


gets filled in with

    char *XDisplayName(char *string);

Inline figures it out from the sub's name

Reply via email to