Objective-C continues to rise in popularity, and so does the need to interoperate with C++ code. Recent changes to the Objective-C language and compilers have partially obsoleted the PIMPL technique I described in a previous article. In this update, I demonstrate the new possibilities and also show how to call from C++ into Objective-C code.
I had some trouble building node.js modules consisting of both C and C++ source files. It took me some time to track down the problem, and the solution isn't especially obvious, so I'm posting this on the web in case anyone else runs into this.
While it appears simple at first ("just use Objective-C++!"), combining Objective-C and C++ code turns out to be trickier than expected in practice. Yet, while using a C++ library in an Objective-C application or vice versa is a reasonably common scenario, the possible solutions are not so well documented. In this article, I explore the core issue and gradually work my way through a variety of solutions, discussing pros and cons. Finally, a solution is presented which is suitable in the vast majority of cases.