5

test.c:

int sum(int a, int b)
{
    return (a+b);
}

test.pl:

# how do I call sum here?
Greg Bacon
  • 134,834
  • 32
  • 188
  • 245
1.618
  • 847
  • 2
  • 11
  • 19

2 Answers2

17
use Inline C => <<'__END_OF_C__';

    int sum(int a, int b)
    {
        return (a+b);
    }

__END_OF_C__

say sum($x,$y);
ikegami
  • 367,544
  • 15
  • 269
  • 518
0

You'll need XS. It's quite involved, so it's best to look at the official manual and tutorial pages for it:

http://perldoc.perl.org/perlxstut.html

http://perldoc.perl.org/perlxs.html

Faiz
  • 16,025
  • 5
  • 48
  • 37