(no title)
MetricExpansion | 2 years ago
Many languages have some facility for importing declarations like that and even using C calling convention to invoke them (e.g. Rust + bindgen), but Swift goes much further than just importing declarations; if the header happens to contain C definition code, it actually compiles that code directly and then can then emit a call to it.
In the case of C++, which doesn't have a stable ABI on most platforms, it likely also knows and emits code using Clang's C++ calling convention for the platform (e.g. Clang on Windows uses the MSVC calling convention and so does Swift when calling C++). But Swift's ability to actually compile C++ code is very powerful in dealing with template functions and classes because Swift can instantiate and compile templated code in the C++ headers. AFAIK it's the only major production language I've seen that even attempts to do this.
No comments yet.