3 ms·
I'm no compiler expert, but I don't see why it has to be so difficult. Just make Rust use the C++ ABI. C++ code is compiled in separate translation units as C
by zelly 7y ago
I'm no compiler expert, but I don't see why it has to be so difficult.
Just make Rust use the C++ ABI.
C++ code is compiled in separate translation units as C++ by the C++ compiler. The linker statically links calls to C++ code from object files created by the C++ compiler. That's it. Rust doesn't need to know how to deal with templates because templates are all instantiated by the time this happens. This means you have to write a lot of your fancy C++ logic in separate C++ source files (not headers), but that's the whole point, to use already written code.
The only thing Rust has to do is pass pointers to static code and follow the calling and name mangling convention. Zero calling overhead.