0Pricing
C++ Academy · Lesson

API Versioning and ABI Stability

Plan for semantic versioning and protect ABI stability across releases.

API Versioning and ABI Stability is a free C++ Academy lesson on CoddyKit — lesson 2 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the C++ Academy learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.

Two Different Compatibilities

Two compatibility concerns:

  • API compatibility — source code that compiles against version N also compiles against N+1
  • ABI compatibility — binaries compiled against version N work with version N+1 without recompiling

Why ABI Matters

ABI compatibility lets shared libraries be upgraded without recompiling dependents. Critical for distributions, plugins, and long-lived applications.

What Breaks ABI

Many innocent-looking changes break ABI:

  • Adding/removing/reordering data members
  • Adding/removing virtual functions
  • Changing inheritance
  • Changing template parameters
  • Inline function changes (sometimes)

Semantic Versioning (SemVer)

Communicate compatibility through version numbers MAJOR.MINOR.PATCH:

  • MAJOR — breaking changes
  • MINOR — new features, backward compatible
  • PATCH — fixes

Versioning Headers

Provide version macros in your headers.

#define MYLIB_VERSION_MAJOR 2
#define MYLIB_VERSION_MINOR 1
#define MYLIB_VERSION_PATCH 3

SONAME for Shared Libraries

On Linux, shared libraries have a SONAME that encodes the major version. Linkers and the loader use it to find compatible versions.

# libmylib.so.2 -> libmylib.so.2.1.3
# SONAME = libmylib.so.2

Hiding Implementation Details

Stable ABIs require keeping the implementation out of headers. Use PIMPL (next lesson) to add or remove private members without affecting consumers.

Compiler ABI

C++ ABI varies between compilers (GCC vs MSVC use different name mangling and class layouts). Distribute binaries built with specific compilers, or stick to extern "C" interfaces.

Standard Library ABI

The standard library can also break ABI — though libstdc++ and libc++ have policies. Avoid std types in your stable public API if you need cross-version compatibility.

Adding Features Compatibly

Safe additions:

  • New free functions
  • New classes
  • New non-virtual member functions (with care)

Unsafe: changing classes that consumers have on stack or compiled in.

Tools for ABI Checking

Tools that compare two builds:

  • abidiff — compares ABI
  • abicompliance-checker — generates reports

Long-Term Strategy

Design for stability up front: small public API, opaque types, careful use of templates and inheritance. Once you ship, breaking ABI is expensive — pin major version bumps and communicate clearly.

Quick Check

Which change to a C++ class is most likely to break ABI?

Recap

API compatibility means source compatibility; ABI compatibility means binary compatibility. ABI is fragile — adding members, virtuals, or changing inheritance breaks it. Use SemVer, hide implementation with PIMPL, ship multiple major versions side by side, and run ABI checkers.

Frequently asked questions

Is the “API Versioning and ABI Stability” lesson free?

Yes — the full text of “API Versioning and ABI Stability” is free to read here on the web, and the C++ Academy course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the C++ Academy course, upgrade to CoddyKit PRO.

What will I learn in “API Versioning and ABI Stability”?

Plan for semantic versioning and protect ABI stability across releases. You practise C++ Academy with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.

Do I need any experience to start C++ Academy?

No prior experience is required. C++ Academy on CoddyKit is structured for beginners through advanced learners; this is — lesson 2 of 4, so you can start here or from the beginning and move at your own pace.

How long does the “API Versioning and ABI Stability” lesson take?

Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.

Can I write and run code in this C++ Academy lesson?

Yes. Every C++ Academy lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.

All lessons in this course

  1. Header-Only vs Compiled Libraries
  2. API Versioning and ABI Stability
  3. Hiding Implementation with PIMPL
  4. Writing a Modern Header-Only Utility Library
← Back to C++ Academy