Perl API 中是否有宏或函数来获取 IV*
的实际整数字段?我可以在 perlguts
和 perlapi
中找到大量信息来获取几乎所有其他类型的值,但我似乎无法理解这一点。
最佳答案
来自 perlguts SvIV(SV*)
应该可以解决问题。
#!/usr/bin/env perl
use strict;
use warnings;
use Inline C => <<'END';
void print_iv (SV* input) {
if (! SvIOK(input))
croak("Not an integer");
printf("Printing integer %d\n", SvIV(input));
}
END
print_iv(3);
关于c - 从 Perl 中的 IV* 中获取整数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16827268/