C++

C++ - ABI (Application Binary Interface) Compatibility

Posted by Rico's Nerd Cluster on April 9, 2023

Introduction and Motivating Example

Two versions of the same library might be API-Compatible (you can recompile your code), but they are not ABI-compatible (you cannot just swap the binary .so without recompiling). Here’s a motivating example:

We have two versions of the same data schema, and some fields are swapped. In serialization / deserialization, it’s common to make assumptions about the order of fields. So such a order change would likeliy not cause compilation issue, but will cause data interpretation issue.

1
2
3
4
5
6
7
8
9
10
11
// Version 1:
struct DataPacket{
    int value1;
    int value2;
};

// Version 2:
struct DataPacket{
    int value2;
    int value1;
};