我正在寻找一种方法来调用一个函数的内联C块目前在一个Perl文件从另一个文件的内联C块。
我有一个perl文件,其中包含内联C块中的get_instrument_price函数
package Dev::Instrument::Price;
use warnings 'all';
use strict;
use Inline C => <<'__END_OF_C__';
int get_instrument_price(int type)
{ return 154; }
__END_OF_C__
还有另一个文件应该调用上述文件以获取仪器价格
package Dev::Instument::Detail;
use warnings 'all';
use strict;
use Inline C => <<'__END_OF_C__';
extern int *get_instrument_price(int type);
int get_instrument_detail(int type)
{
# some code
int instrument_price = get_instrument_price(type);
# some more code
}
__END_OF_C__
我试过使用LIBS => '-L/_Inline/lib/auto'
,就像下面的参考文献中提到的那样,对我不起作用。
引用自:
1条答案
按热度按时间kxe2p93d1#
一种解决方法是将常见的C函数拆分到一个单独的库中,例如:
libincodile/instrument.c:
libincodile/instrument.h:
lib/Dev/Instrument/Detail.pm:
lib/Dev/Instrument/Price.pm:
p.pl:
编译公共库:
输出: