Getting Object Functionality out of C++ code in C#

后端 未结 3 1895
伪装坚强ぢ
伪装坚强ぢ 2021-01-14 22:43

I have have a function in wrote in C++ that calls some functions in a old lib. This function creates some memory makes the calls and destroys the memory. To optimize this I

3条回答
  •  轮回少年
    2021-01-14 23:15

    I prefer to write a managed wrapper in C++/CLI (formerly Managed C++), as it makes it much easier to explicitly do what you want with managed/unmanaged interoperability on the C++ side, and your C# doesn't get polluted with P/Invoke style code.

    Edit Just noticed your comment "However I'm going to be calling this function from C# and don't believe I can export a Class, just functions or variables."

    That's not entirely true - C# can import full classes from an assembly generated from C++/CLI code.

提交回复
热议问题