Calling 'C' function from Perl

Discussion in 'Perl Misc' started by Sankar, Feb 15, 2007.

  1. Sankar

    Sankar Guest

    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
     
    Sankar, Feb 15, 2007
    #1
    1. Advertising

  2. Marco Neumann, Feb 15, 2007
    #2
    1. Advertising

  3. Sankar

    Mumia W. Guest

    On 02/14/2007 11:49 PM, Sankar wrote:
    > 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


    --
    Windows Vista and your freedom in conflict:
    http://techdirt.com/articles/20061019/102225.shtml
     
    Mumia W., Feb 15, 2007
    #3
  4. Sankar

    Sisyphus Guest

    "Sankar" <> wrote in message
    news:...
    > 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";
    -----------------

    Cheers,
    Rob
     
    Sisyphus, Feb 15, 2007
    #4
  5. Sankar

    Sankar Guest

    On Feb 15, 5:30 am, "Sisyphus" <> wrote:
    > "Sankar" <> wrote in message
    >
    > news:...
    >
    >
    >
    > > 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";
    > -----------------
    >
    > Cheers,
    > Rob


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

    Regards
    Sankar
     
    Sankar, Feb 15, 2007
    #5
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Andreas Lagemann
    Replies:
    8
    Views:
    502
    Mike Wahler
    Jan 10, 2005
  2. tiwy
    Replies:
    0
    Views:
    453
  3. pj
    Replies:
    3
    Views:
    300
  4. kath
    Replies:
    4
    Views:
    699
    J. Gleixner
    Apr 9, 2007
  5. Bill H

    Flash calling Php calling Perl

    Bill H, Jun 4, 2009, in forum: Perl Misc
    Replies:
    3
    Views:
    256
    Mark Smith
    Jun 4, 2009
Loading...

Share This Page