Calling 'C' function from Perl

S

Sankar

Dear All,
I am developing a C application on a linux platform that has many
functions . My requirement is to call those functions from Perl.

I would appreciate if you could give some pointers in this regard.

My requirement is sth like this

C fucntion

int square( int a)
{
....
....
return(a)

}

in my perl file i should be able to do this.

a = square( 10)


Thanks in advance
Regards
Sankar
 
M

Mumia W.

Dear All,
I am developing a C application on a linux platform that has many
functions . My requirement is to call those functions from Perl.

I would appreciate if you could give some pointers in this regard.
[...]

perldoc perlxs
 
S

Sisyphus

Sankar said:
Dear All,
I am developing a C application on a linux platform that has many
functions . My requirement is to call those functions from Perl.

I would appreciate if you could give some pointers in this regard.

My requirement is sth like this

C fucntion

int square( int a)
{
...
...
return(a)

}

Marco has pointed you in the right direction. More specifically:

-----------------
use warnings;
use Inline C => Config =>
BUILD_NOISY => 1;

use Inline C => <<'EOC';

int square(int a) {
return a * a;
}

EOC

$a = 173;
$a = square($a);
print $a, "\n";
 
S

Sankar

Marco has pointed you in the right direction. More specifically:

-----------------
use warnings;
use Inline C => Config =>
BUILD_NOISY => 1;

use Inline C => <<'EOC';

int square(int a) {
return a * a;

}

EOC

$a = 173;
$a = square($a);
print $a, "\n";

Thanks a lot everyone for your response.. Ur help is greatly
appreciated !!

Regards
Sankar
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,046
Latest member
Gavizuho

Latest Threads

Top