Home > Net >  Using C wrapper of C code for ABI stability?
Using C wrapper of C code for ABI stability?

Time:03-20

In his C wrapper illustration

Here "BinaryLibrary" and "Old C stdlib" use an old ABI, and "NewExecutable" uses a hypothetical updated ABI.

As far as I understand, this works since old C ABI of "BinaryLibrary" gets baked into a separate binary with a more stable interface.

But what makes C a good alternative? Can't its ABI change as well?

CodePudding user response:

Can the C ABI change? Well, not easily. There have been occasional changes on some platforms, but so many systems and languages are built using the C ABI as a public interface that it has to be quite stable. Many languages have a C FFI which allows them to call C functions, and changing the C ABI would break those. And the C ABI is a common way of interacting with the operating system, e.g. to open files or send messages, so it's used by many language implementations (e.g. interpreters and standard libraries).

Note that the C ABI is not part of the C standard. Each platform or system can define its own C ABI. So while it tends to be stable over time on a given platform, it is not consistent across all platforms.

  • Related