dongme8388 2018-08-03 11:23
浏览 62

PHP(5.5.9)SWIG:如何将指向boolean的指针作为参数传递?

I am using SWIG (3.0.12) with PHP (5.5.9) to build to the following C++ method (in class arith_uint256):

arith_uint256& SetCompact(uint32_t nCompact, bool *pfNegative = NULL, bool *pfOverflow = NULL);

SWIG writes this to the wrapper PHP:

function SetCompact($nCompact, $pfNegative=null, $pfOverflow=null) {
    $r=arith_uint256_SetCompact($this->_cPtr,$nCompact,$pfNegative,$pfOverflow);
    if (!is_resource($r)) return $r;
    return new arith_uint256($r);
}

It compiles fine, and I can call the method without the optional args pfNegative and pfOverflow. However, I can't figure out how to pass by-ref those boolean parameters (passing null is ok, but can't figure out how to pass pointer to boolean).

Explicit pass-by-reference is deprecated on the calling side in PHP. Adding reference symbol "&" to the args in the SWIG-outputted wrapper class also does not help.

PHP emits:

PHP Fatal error: No matching function for overloaded 'arith_uint256_SetCompact' in Uint256/Uint256.php on line 113

The SWIG type in question is: "SWIGTYPE_p_bool"

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 ETLCloud 处理json多层级问题
    • ¥15 matlab中使用gurobi时报错
    • ¥15 这个主板怎么能扩出一两个sata口
    • ¥15 不是,这到底错哪儿了😭
    • ¥15 2020长安杯与连接网探
    • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
    • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
    • ¥16 mybatis的代理对象无法通过@Autowired装填
    • ¥15 可见光定位matlab仿真
    • ¥15 arduino 四自由度机械臂