---
title: "Version & ABI"
description: "Compile-time version identification plus per-class ABI-tier macros. Application code that must adapt to the SDK it builds against (#if ALPVERSIONAT_LEAST(...)) or feature-test an ABI tier reads everything it needs from this one header."
source: https://docs.alplab.ai/sdk/api/version
---

# `<alp/version.h>` — Version & ABI Feature-Test

Compile-time version identification plus per-class ABI-tier macros. Application code that must adapt to the SDK it builds against (`#if ALP_VERSION_AT_LEAST(...)`) or feature-test an ABI tier reads everything it needs from this one header.

This header is `[ABI-STABLE]`: the macro **names** and the composite encoding are frozen. The numeric **values** change every release by design, and the per-class `ALP_ABI_STATUS_*` values move only via a deliberate promotion PR.

## Header

```c
#include <alp/version.h>
```

## Compile-time version macros

The numeric macros track the SDK release (`metadata/sdk_version.yaml`) and are rewritten on every version bump — never hand-edit them.

| Macro                                | v0.17.0 value                         | Notes                                              |
|--------------------------------------|---------------------------------------|----------------------------------------------------|
| `ALP_VERSION_MAJOR`                  | `0`                                   | ABI-breaking changes bump this.                    |
| `ALP_VERSION_MINOR`                  | `17`                                  | Additive ABI changes bump this.                    |
| `ALP_VERSION_PATCH`                  | `0`                                   | Fixes with no surface change.                      |
| `ALP_VERSION_STRING`                 | `"0.17.0"`                            | String literal, `"MAJOR.MINOR.PATCH"` — or, on a release-candidate build, SemVer pre-release syntax such as `"0.9.0-rc1"`. |
| `ALP_VERSION_ENCODE(maj, min, pat)`  | `(maj << 16) \| (min << 8) \| pat`    | Encode a triple into one comparable integer.       |
| `ALP_VERSION`                        | `ALP_VERSION_ENCODE(0, 17, 0)`        | This SDK's version as one comparable integer.      |
| `ALP_VERSION_AT_LEAST(maj, min, pat)`| `ALP_VERSION >= ALP_VERSION_ENCODE(…)`| Compile-time "at least" check, usable in `#if`.    |

:::note[Release candidates]
`ALP_VERSION_MAJOR` / `_MINOR` / `_PATCH` always stay the plain core integers, so an rc build of 0.17.0 compares equal to 0.17.0 in `ALP_VERSION_AT_LEAST`. `ALP_VERSION_STRING` (and `alp_version_string()`, which returns it verbatim) is the only place that can tell an rc build apart from the GA version it targets.
:::

### Feature-testing a version

`ALP_VERSION_AT_LEAST` expands to a preprocessor-constant expression, so it works directly in `#if`:

```c
#if ALP_VERSION_AT_LEAST(0, 9, 0)
    // use a surface introduced in v0.9.0 (e.g. alp_i2c_target_open)
    alp_i2c_target_t *tgt = alp_i2c_target_open(&cfg);
#else
    // fall back for older SDKs
#endif
```

## ABI-tier macros

Every public header declares one ABI tier via its `@par ABI status:` marker. `<alp/version.h>` exposes that classification to the preprocessor so application code can feature-test a class before depending on it.

| Macro                  | Value | Meaning                                              |
|------------------------|-------|------------------------------------------------------|
| `ALP_ABI_EXPERIMENTAL` | `1`   | Surface may change in any minor release.             |
| `ALP_ABI_STABLE`       | `2`   | Frozen; removals / renames require a major bump.     |

Each peripheral / service class carries an `ALP_ABI_STATUS_<CLASS>` macro set to one of the two tiers above:

```c
#if ALP_ABI_STATUS_STORAGE == ALP_ABI_STABLE
    // rely on <alp/storage.h> staying frozen until the next major
#endif
```

### Per-class ABI status (v0.17.0)

| Class(es)                                                                                         | ABI tier               |
|---------------------------------------------------------------------------------------------------|------------------------|
| `GPIO`, `I2C`, `SPI`, `UART` (all of `<alp/peripheral.h>`)                                         | `ALP_ABI_STABLE`       |
| `ADC`, `DAC`, `PWM`, `CAN`, `RTC`, `WDT`, `COUNTER`, `I2S`, `AUDIO`                                | `ALP_ABI_STABLE`       |
| `BLE`, `IOT`, `SECURITY`, `INFERENCE`, `MPROC`, `HW_INFO`, `GUI`, `RPC`                            | `ALP_ABI_STABLE`       |
| `STORAGE`, `USB`, `POWER`, `CAMERA`, `DISPLAY`, `DSP`, `GPU2D`, `TMU`                              | `ALP_ABI_EXPERIMENTAL` |
| `MODEL`, `UPDATE_LOG`, `BACKEND`, `CAP`, `TEMPERATURE` (new in v0.17.0)                            | `ALP_ABI_EXPERIMENTAL` |

:::note
`ADC`'s base surface is stable, but its newer filter / spectrum additions stay experimental at function granularity — see the [ADC](https://docs.alplab.ai/sdk/api/adc) page and the header. Function-level experimental additions inside an otherwise-stable class (e.g. `<alp/peripheral.h>`'s I²C/SPI **target-mode** surface) are likewise marked in the header, not in `ALP_ABI_STATUS_*`.
:::

:::caution[Not every header has an ABI-tier macro]
[`<alp/ahrs.h>`](https://docs.alplab.ai/sdk/api/ahrs) and [`<alp/pid.h>`](https://docs.alplab.ai/sdk/api/pid) are both `[ABI-EXPERIMENTAL]` per their file-level markers, but `<alp/version.h>` ships **no** `ALP_ABI_STATUS_AHRS` / `ALP_ABI_STATUS_PID` macro — so they cannot be feature-tested this way. Gate on `ALP_VERSION_AT_LEAST(0, 10, 0)` (or the `CONFIG_ALP_SDK_AHRS` / `CONFIG_ALP_SDK_PID` build knobs) instead. The same holds for [`<alp/i3c.h>`](https://docs.alplab.ai/sdk/api/i3c) and [`<alp/jpeg.h>`](https://docs.alplab.ai/sdk/api/jpeg): there is no `ALP_ABI_STATUS_I3C` or `ALP_ABI_STATUS_JPEG`.
:::

## Runtime version getter

```c
const char *alp_version_string(void);
```

Returns the SDK release as a static `"MAJOR.MINOR.PATCH"` string; **never NULL**. The header documents it as returning `ALP_VERSION_STRING` verbatim, so on an rc build it carries the pre-release suffix.

### Compile-time vs link-time

`ALP_VERSION_STRING` is baked from the **header** you compiled against. `alp_version_string()` reports the SDK the application was **linked** against. When the SDK is consumed as a shared library, the runtime can be newer than the header at compile time — compare the two to detect that skew:

```c
printf("built against %s, linked against %s\n",
       ALP_VERSION_STRING, alp_version_string());
```

## See also

- [API Overview](https://docs.alplab.ai/sdk/api/overview) — the full header surface
- [`<alp/peripheral.h>`](https://docs.alplab.ai/sdk/api/peripheral) — GPIO / I²C / SPI / UART, including v0.9 target-mode
- [`docs/abi/README.md`](https://github.com/alplabai/alp-sdk/blob/main/docs/abi/README.md) — the ABI policy
