4 ms·
The point is that data layout is an implementation detail not part of the C++ API, and exposing that through shared libraries isn't a great idea. People do it,
by chubot 6y ago
The point is that data layout is an implementation detail not part of the C++ API, and exposing that through shared libraries isn't a great idea. People do it, but it's a big mess and not particularly well documented.
You can write conformant STL implementations that have completely different layouts. But the GNU one no longer had a valid layout, so it had to change.
So when you expose libstdc++ as a shared library, you're exposing a bunch of details that aren't part of the C++ standard.
If you write it in a header, then you can expect it to break callers via shared library. And templates must be in headers. This is a fundamental language issue.
I don't use Rust, but the point is "making a stable ABI" will expose it to these sorts of problems, i.e. implementation details leaking on specific architectures, outside of the language.
The projects that care about ABI stability, e.g. sqlite, don't expose layouts. They have only functions and not data in their headers.
- gpderetta 6y agoThis thread is getting confusing. Your original point was that for binary compatibility you write against the C ABI. I'm claiming that the C ABI has exactly the same fragile layout limitations and you can use the exact same workarounds in C++ (i.e. only expose pointers or make sure that your layout doesn't change). I'm also claiming that templates are a red herring and have very little to do with ABI.