Call a function in a shared library: Difference between revisions

Content added Content deleted
(→‎{{header|Perl 6}}: update for more strict type constraints)
m (→‎{{header|Perl 6}}: Update to work with 64 bit IDs (fix segfault))
Line 1,246: Line 1,246:
See [[Call_a_function_in_a_shared_library#Delphi | Delphi]]
See [[Call_a_function_in_a_shared_library#Delphi | Delphi]]
=={{header|Perl 6}}==
=={{header|Perl 6}}==
{{works with|Rakudo|2018.03}}
{{works with|Rakudo|2018.11}}
<lang perl6>use NativeCall;
<lang perl6>use NativeCall;


sub XOpenDisplay(Str $s --> int64) is native('X11') {*}
constant libX11 = '/usr/lib/x86_64-linux-gnu/libX11.so.6';
sub XCloseDisplay(int64 $i --> int32) is native('X11') {*}

sub XOpenDisplay(Str $s --> int32) is native(libX11) {*}
sub XCloseDisplay(int32 $i --> int32) is native(libX11) {*}


if try my $d = XOpenDisplay ":0.0" {
if try my $d = XOpenDisplay ":0.0" {
Line 1,259: Line 1,257:
}
}
else {
else {
say "No library {libX11}!";
say "No X11 library!";
say "Use this window instead --> ⬜";
say "Use this window instead --> ⬜";
}</lang>
}</lang>
{{out}}
{{out}}
<pre>ID = 124842864</pre>
<pre>ID = 94722089782960</pre>


=={{header|Phix}}==
=={{header|Phix}}==