C++/Rust Interoperability Problem Statement

6 pointsposted 2 days ago
by weinzierl

1 Comments

hedora

a day ago

I wonder if the approach swift took will generalize:

C++ (and Rust) need to see the set of template (generic) instantiations you actually use, so just including a C++ header isn’t enough to get interop to work. Instead, you need to somehow emit the appropriate template instantiations on the C++ side, then emit public linker symbols for them.

Swift <-> C++ bypasses this by letting the (llvm-based) swift compiler reach into clang++ and llvm’s guts and create the right instantiations / symbols.

I’m not sure if that could be made to work with vc++ or g++.