I have a C++ API prototype
void Func(int& size);
How can I translate it to P/Invoke in C#?
From what I know, if I use
public static extern Func(ref int size);
, the function will receive a pointer to the int instead of the value.
(Ooops... meant this as an answer, not a comment).
And when you call it from C++, the function will receive a pointer also. How else do you think references are implemented? Func() will treat that pointer as a reference, so how it gets there isn't important.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.