Logo

Programming-Idioms

History of Idiom 190 > diff from v5 to v6

Edit summary for version 6 by daxim:
New Perl implementation by user [daxim]

Version 5

2019-09-28, 15:33:45

Version 6

2019-10-07, 04:47:35

Idiom #190 Call an external C function

Declare an external C function with the prototype

void foo(double *a, int n);

and call it, passing an array (or a list) of size 10 to a and 10 to n.

Use only standard features of your language.

Idiom #190 Call an external C function

Declare an external C function with the prototype

void foo(double *a, int n);

and call it, passing an array (or a list) of size 10 to a and 10 to n.

Use only standard features of your language.

Extra Keywords
C interoperability
Extra Keywords
C interoperability
Imports
use FFI::Platypus qw();
Code
FFI::Platypus
    ->new(lib => '/tmp/mylib/libmylib.so')
    ->attach(foo => ['double[]', 'int']);
foo([1..10], 10);
Doc URL
http://p3rl.org/FFI::Platypus