c call

G

George Mpouras

At windows I can call a C function as end user, using the Win32::API
Can I do something similar at Linux ?
Do not mention the inline because we assume that there is so access to C
source.

R

Rainer Weikusat

George Mpouras said:
At windows I can call a C function as end user, using the Win32::API
Can I do something similar at Linux ?

AFAIK, no, as this would require generating different kinds of 'glue
code' at run time, depending on whatever the calling conventions of the
current platform happen to be.

P

Peter Makholm

George Mpouras said:
At windows I can call a C function as end user, using the Win32::API
Can I do something similar at Linux ?
Do not mention the inline because we assume that there is so access to
C source.

Never tried it myself, but try look at FFI::Library or FFI::Raw.

//Makholm

\$

\$Bill

AFAIK, no, as this would require generating different kinds of 'glue
code' at run time, depending on whatever the calling conventions of the
current platform happen to be.

Easy enough to do, I would think, if you compile in a constant that tells
you which calling convention the compiler is using.

R

Rainer Weikusat

\$Bill said:
Easy enough to do, I would think, if you compile in a constant that tells
you which calling convention the compiler is using.

I don't know how the FFI module works internally (and can't easily
determine that at the moment), but a naive approach would need explicitly written,
platform-specific machine code.

I

ilovelinux

Op woensdag 26 maart 2014 13:35:43 UTC+1 schreef George Mpouras:
At windows I can call a C function as end user, using the Win32::API
Can I do something similar at Linux ?
Do not mention the inline because we assume that there is so access to C
source.

How about the Inline module which makes it trivial to embed calls to other languages from Perl programs.
http://search.cpan.org/dist/Inline/Inline.pod