Import a C++ .lib and .h file into a C# project?

前端 未结 3 2214
北海茫月
北海茫月 2020-12-10 10:28

I have just started a C# project and want to import a C++ .lib and it\'s corresponding header (.h) file.

I\'ve read various posts that all mention .dll, rather than

3条回答
  •  天涯浪人
    2020-12-10 11:17

    It is 'as hard as it seems'. C++ and C# are ambivalent. The first has deterministic destruction, the second not. Now, you write C++/cli delaying the destruction to some finalizer called by the garbage collector working in it's own thread, introducing problems all over the place (thread safety, are C++ members (used in c++/cli) valid?, ...). Even worse the GC might suggest C++ objects being tiny (a pointer) and provoke a kind of memory leak (due to late deallocating tiny objects). Essentially you end up in writing a GC on top of the C++/cli GC to delete non C++/cli (!) objects in the main thread or another. All that is insane, ...

提交回复
热议问题