3 ms·
> If you want to distribute your library as a binary object and a separate source-form interface/header today, you'll have to use a (wrapper) C API. This is on
by jjnoakes 10y ago
> If you want to distribute your library as a binary object and a separate source-form interface/header today, you'll have to use a (wrapper) C API.
This is only true if you want to target different compilers. If you ship your binaries targeting a specific compiler (which is what just about every company does that I've ever worked with), you don't have any abi issues.
- paulasmuth 10y agoActually, you can even have incompatibilities with the same compiler and different compile flags. So to reliably build a "semi-portable" c++ object one would have to ensure that all objects are compiled with the exact same (i.e. same version of the compiler/same compiler source code) and with the exact same flags. I'm sure there are some compiler vendors that offer ABI backwards-compatibility but it's not part of the C++ language per-se. See this article by Herb Sutter on the topic: https://isocpp.org/files/papers/n4028.pdf https://isocpp.org/files/papers/n4028.pdf
- jjnoakes 10y agoOh I'm well aware; as my comment indicated, I've been doing this a long time. I didn't want to get in to the full details in a HN comment, but yes, there's definitely a few things you have to coordinate on between vendors if you want to ship C++ libraries that work together.