Wrapping C++ class API for C consumption

后端 未结 6 1420
滥情空心
滥情空心 2020-12-02 08:07

I have a set of related C++ classes which must be wrapped and exported from a DLL in such a way that it can be easily consumed by C / FFI libraries. I\'m looking for some \"

6条回答
  •  生来不讨喜
    2020-12-02 08:41

    First, you might not need to convert all your methods to C functions. If you can simplify the API and hide some of the C++ interface, it is better, since you minimize the chance to change the C API when you change C++ logic behind.

    So think of a higher level abstraction to be provided through that API. Use that void* solution you described. It looks to me the most appropriate (or typedef void* as HANDLE :) ).

提交回复
热议问题