by makecheck · 14y ago · 0 comments
C++ is useful for implementing the guts of things. And when implementing, having your own library of shared C++ code is useful, as long as you completely control it and always compile it with your project from scratch (a library of templates, for instance). The last thing you want is to link to someone else's compiled C++ library because that's where the pain begins.
To expose a C++ implementation, use a plain C interface; the C application binary interface works very well across compilers. If you feel it absolutely necessary to expose something like the inheritance scheme of an object-oriented design, you had better do it in a language like Objective-C that can at least implement objects in a very forward-compatible way (or use tricks like exposing pointer parameters in C functions).
Both work but the c libraries have a more inconsistent object model and require multi-stage processes for the construction of their c-objects.
Once a c-based project is large enough that it needs objects in user space, not have a c++ interface is counter-productive and backporting to c++ project to c would doubly counter-productive here.