C doesn't have function overloading. You're probably looking at C++ code. Unfortunately, even if you compile that code using something like Inline::CPP you're going to have to use different function names in some way, because XS, which is built on C, won't be able to bind two functions in the same namespace with the same name.
use strict; use warnings; use Inline CPP => 'DATA'; print add( 1, 1 ), "\n"; print add( 1, 1, 1 ), "\n"; __DATA__ __CPP__ int add ( int a, int b ) { return a + b; } int add( int a, int b, int c ) { return a + b + c; }
...outputs...
Usage: main::add(a, b, c) at ./mytest.pl line 7.
...where line 7 is the add( 1, 1 ) call.
Perl can't be expected to understand C++'s rules for resolving overloading. And since Perl is a dynamic language, the C or C++ linker can't make the decision either.
Dave
In reply to Re: Can't create XSUBs for C functions with a same name
by davido
in thread Can't create XSUBs for C functions with a same name
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |