开发者

call c++ function with reference parameter from cli

The unmanaged function(pure c++, if that matters):

 voi开发者_如何学JAVAd fooC(float& result);

I define the wrapper as (managed wrapper, c++\cli):

void foo(float% result) //managed interface, need to pass result back to caller
{
      fooC(???);//how to call unmanaged function?
}

how to pass reference parameter in the wrapper?


You can't convert a tracking reference to an unmanaged reference or pointer. The garbage collector would cause havoc when the passed float is a field in an object. You'll need to use a temporary:

  void foo(float% result) { 
    float temp;
    fooC(temp); 
    result = temp;
  }
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜