Skip to content

The stable ABI and the deprecation policy

A game built against 360sona 1.x keeps working when the library under it is replaced by a later 1.x. This page says what that promise covers, how a program checks it at run time, and how the build checks it before a release.

The promise

Within a major version:

  • Nothing breaks for two minor versions. A function, struct, enum value or constant can be marked deprecated in a minor release. It still works in that release and the next one. It can be removed in the release after that, and not before: deprecated in 1.x, still there in 1.x and 1.(x+1), gone at the earliest in 1.(x+2). A deprecation can be kept longer than that, to a version named with it. The editor's SONA_EDITOR_SCREEN_FACE, _HAIR and _COLOURS stay until 2.0.
  • Struct layouts never change. Every struct keeps its size, its alignment and the offset and size of every field. A struct grows only into its reserved words: a new field takes the place of some of them, and the struct's size stays the same.
  • Numbers keep their meaning. Every SONA_* constant, every enum value and every result code keeps its value.
  • Exports stay. Every function in sona.def (and the modules' .def files) stays exported, from the same library, with a declaration that still accepts what callers built against the older header pass.
  • SONA_ABI stays. It changes only with the major version.

A new major version may change any of this, and says what changed in its release notes.

At run time: sona_abi_query

Hosts and bindings that load the library at run time can ask which ABI it has:

sona_abi_info i = { 0 };
i.size = sizeof i;
if (sona_abi_query(&i) == SONA_OK && SONA_ABI >= i.oldest_abi &&
    SONA_ABI <= i.abi) {
  /* this program, built against SONA_ABI, can use the library */
}
sona_abi_info i;
if (sona::abi(i) == SONA_OK && SONA_ABI >= i.oldest_abi &&
    SONA_ABI <= i.abi) {
  // this program, built against SONA_ABI, can use the library
}
var i = new Native.sona_abi_info();
i.size = (uint)sizeof(Native.sona_abi_info);
if (Native.sona_abi_query(&i) == SonaResult.Ok &&
    Native.SONA_ABI >= i.oldest_abi && Native.SONA_ABI <= i.abi)
{
    // this program, built against SONA_ABI, can use the library
}
let i = abi()?;
if sona_sys::SONA_ABI >= i.oldest_abi && sona_sys::SONA_ABI <= i.abi {
    // this program, built against SONA_ABI, can use the library
}
i = sona.abi()
if i["oldest_abi"] <= 1 <= i["abi"]:
    pass  # this package, built against ABI 1, can use the library
  • abi is the library's SONA_ABI, oldest_abi the oldest SONA_ABI a caller may be built against.
  • major, minor and patch are its version (sona_version() gives the same as text).
  • size is in and out: set it to sizeof(sona_abi_info) as your header has it. The library writes only as much as both of you know and sets size to that. A size smaller than the version numbers is SONA_E_ARGUMENT.

The bindings also compare every struct size and field offset they mirror with the library's own (sona_struct_size, sona_struct_offset) before they open a context, so a mismatched library is refused with a message instead of misread.

Binding Call
C++ sona::abi(info)
C# Native.sona_abi_query
Python sona.abi()
Rust sona::abi()

This page as Markdown · All the docs as one file (llms-full.txt)