C Wrapper for C++

前端 未结 4 1324
心在旅途
心在旅途 2020-12-13 15:46

I\'d like to use Pure Data as a prototyping tool for my own library. I found out that Pure Data patches are written in C, but my library is written in C++. So how can I use

4条回答
  •  南方客
    南方客 (楼主)
    2020-12-13 16:38

    Let me put it another way:

    1) You can call C functions, data and libraries from C++ source, and you call C++ source from C.

    2) Whenever C calls into C++ source, however, that source must be written in a C subset of C++.

    3) Part of this is using "extern C".

    4) Another part is using "#ifdef __cplusplus"

    5) The links I cited above give plenty of details

    6) I looked at the Pure Data site. You might have to make some "tweaks" to your library. You might wish to create a new header. But fundamentally, I think you can probably accomplish your goal of getting your library to integrate with Pure Data.

    IMHO...

提交回复
热议问题