3 ms·
> Very good compatibility with C code How much harder would it be to call C++?
by hobo_mark 11y ago
> Very good compatibility with C code
How much harder would it be to call C++?
- KenoFischer 11y agoDepends how much of C++ you need. In full generality you need a C++ compiler in the calling compilation unit (inlining, template instantiation, etc.). The name mangling and ABI itself really isn't that hard.
- azakai 11y agoIt might be interesting to use the clang frontend and modify it to emit QBE instead of LLVM. I believe Visual Studio and ICC do that.
- andrewchambers 11y agoOne thought i had would be make a qbe backend for llvm, just as a temporary solution until there are faster smaller frontends that can replace them.
- ori_b 11y agoThe same difficulty,more or less. Mangle in your front-end. The problem comes from the fact that half of C++ lives in headers in the form of templates, so there isn't any code to call, from the perspective of a compiler back end. To link against code using things like the STL, your compiler would basically need to understand how to compile C++. Same problem as macros in C, but macros are usually less pervasive in C code, meaning that often you get a good enough binding by ignoring them or filling in wrapper functions by hand.
- deleted 11y ago[deleted]