int %tmp
C++/CLIをネイティブ C++に変換するにはどうすればよいint &tmp
ですか?
void test(int %tmp)
{
// here I need int &tmp2 for another pure C++ function call
}
int %tmp
C++/CLIをネイティブ C++に変換するにはどうすればよいint &tmp
ですか?
void test(int %tmp)
{
// here I need int &tmp2 for another pure C++ function call
}
高度なユースケースは言うまでもなく、既存の回答はどちらもイン/アウトパラメータを適切に処理しません。
other_func
これは、参照が戻った後に参照を保持しないすべての場合に機能するはずです。
void test(int %tmp)
{
pin_ptr<int> pinned_tmp = &tmp;
other_func(*pinned_tmp);
}
これを試してみましたが、うまくいきます:
//in the C++ dll
void testFunc( int& n )
{
n = 5;
}
//in the CLI app
[DllImport( "my.dll", EntryPoint = "?exported_name_here",
CallingConvention = CallingConvention::StdCall )]
void TestFunc( int& );
void test( int% tmp )
{
int n;
TestFunc( n );
tmp = n;
}
void your_function(int *);
void your_function2(int &);
void test(int %tmp)
{
int tmp2;
your_function(&tmp2);
your_function2(tmp2);
tmp=tmp2;
}