[cecilia] Making Cecilia more palatable for C++ compilers ?
Lately, two persons independently asked me whether it was possible to make C++ programs with Cecilia (or at least, use a C++ compiler with Cecilia).
I knew it would not work with all compilers and platforms, if nothing else for ABI reasons (mixing C and C++ doesn't always work...) and possibly name mangling for the Cecilia VFT: there are no conditional "extern C {}" blocks in the runtime and generated glue code, and those may be necessary in some situations. It may be that I'm missing potential concerns, or that I'm having too many concerns: my C++ skills are low. So I tried. Results on x86 Linux, on the Cecilia examples:
-
helloworld: build succeeds when using g++ (4.1) instead of gcc (4.1) as both compiler and linker. At first try, I had forgotten to use g++ as a linker, so there was a linking error... My bad. The resulting binary is linked against libstdc++ and contains mangled function names; it prints the expected sequence of messages.
-
comanche: when using the single-thread scheduler, build succeeds without modifications to the code. When using the multi-thread scheduler, the compiler complains about an invalid conversion from 'void *' to another pointer type, which can be solved by static_cast<> or reinterpret_cast<>. Both resulting binaries survive a HTTP performance test.
-
cloneable: the compiler complains about various forbidden conversions from 'void *' to other pointer types, same solution as above could be applied to them. Some of them are in the Cecilia runtime, cloneableComposite.c.
So it would seem that name mangling is not a concern, but the main source of trouble (for my small sample of applications) is other semantic differences between C and C++, some of which affect the runtime (and possibly the generated glue code too).
Is it, in your opinion, worth the trouble making the Cecilia runtime and Cecilia-generated glue code more interoperable with C++ compilers ?