Yes, so while this technique would be harder to adopt for a library, or at least harder on the users, for an application where you don't really need to worry about people using C calling into your code, it would be fairly useful. A short HOWTO on how to call from C using the necessarily included and emulated C++ vtable bits would make calling in from C possible and easier where required, but you could still reap the benefits of non-C features while sticking with a C toolchain at the lowest level.
Re:Object-oriented techniques in C
by nostrademons on Tuesday September 22, 2015 @08:59PM
(#10262749)
Usually an 'extern "C" { .... }' declaration is easier if you control the C++ library code.
I see what's being talked about now. I misinterpreted meson2k's original reply, so haven't really been on the same page as you or him.
If current C++ to C transpilers don't handle naming well, that's a problem that should be worked on.
If you got rid of name mangling (and a few other C++ features that are besides the point), you could certainly call C++ from C. The thing is - your C calls would look exactly like what the article is suggesting. That's why it's important to learn this technique: it is what your C++ compiler is doing under the hood. Indeed, the very first C++ compilers were just preprocessors that transformed C++ syntax into the type of vtable + base class + first parameter indirection that you see here.