views:

188

answers:

1

The unmanaged function(pure c++):

 void 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?

+2  A: 

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;
  }
Hans Passant