3
我有在C++函数,例如:返回C++指针到perl
void* getField(interface* p)
{
int* temp = new int(p->intValue);
cout<< "pointer value in c++" << temp << "value of temp = " << temp << endl;
return temp;
}
我使用SWIG以产生用于上述类包装。现在我试图在Perl中获取返回的指针值。我该怎么做??
我写了下面的perl脚本调用的函数:
perl
use module;
$a = module::create_new_interface();
$b = module::getField();
print $b,"\n";
print $$b, "\n";
我ahve正确,因为在调用函数getfield命令()接口的正确的intValue获取打印定义的create_interface功能。
的程序的输出是如下:
_p_void=SCALAR(0x5271b0)
5970832
pointer value in c++ 0x5b1b90 value of temp 22
为什么两个值 - 在C++指针和在Perl不同的参考?如何从引用中获取intValue? (即该值22)