Getting the haiku version

I have a function that gets the OS version and prints it for support reasons. And I would’ve thought that there was an API to get that somewhere. And indeed I found get_system_info in OS.h that returns a “kernel_version”. But that’s hard coded to “1”. Should it not be set to B_HAIKU_VERSION? (Really B_HAIKU_VERSION_1_BETA_4…)

Is the only way to run the uname process and parse the output?

Edit: I’ve found ‘__get_haiku_revision’ which gives me the hrev… still need the “which beta”…

1 Like

OOoooooh… there is a “uname” api… but that still doesn’t give me which beta it is?

This is how AboutSystem get’s the OS version:

Seems it gets the “R1/beta4” (at the moment for me), from the BEOS:APP_VERSION attribute of


That’s one option, or you can use get_image_info, find or there, and check it’s “abi” and “api_version” fields. First check that abi is “B_HAIKU_ABI” (in case you’re not running on Haiku?) and then check api_version against the list defined in BeBuild.h:

headers/os/BeBuild.h:#define B_HAIKU_VERSION_BEOS                       0x00000001
headers/os/BeBuild.h:#define B_HAIKU_VERSION_BONE                       0x00000002
headers/os/BeBuild.h:#define B_HAIKU_VERSION_DANO                       0x00000003
headers/os/BeBuild.h:#define B_HAIKU_VERSION_1_ALPHA_1          0x00000100
headers/os/BeBuild.h:#define B_HAIKU_VERSION_1_PRE_ALPHA_2      0x00000101
headers/os/BeBuild.h:#define B_HAIKU_VERSION_1_ALPHA_2          0x00000200
headers/os/BeBuild.h:#define B_HAIKU_VERSION_1_PRE_ALPHA_3      0x00000201
headers/os/BeBuild.h:#define B_HAIKU_VERSION_1_ALPHA_3          0x00000300
headers/os/BeBuild.h:#define B_HAIKU_VERSION_1_PRE_ALPHA_4      0x00000301
headers/os/BeBuild.h:#define B_HAIKU_VERSION_1_ALPHA_4          0x00000400
headers/os/BeBuild.h:#define B_HAIKU_VERSION_1_PRE_BETA_1       0x00000401
headers/os/BeBuild.h:#define B_HAIKU_VERSION_1_BETA_1           0x00000500
headers/os/BeBuild.h:#define B_HAIKU_VERSION_1_PRE_BETA_2       0x00000501
headers/os/BeBuild.h:#define B_HAIKU_VERSION_1_BETA_2           0x00000600
headers/os/BeBuild.h:#define B_HAIKU_VERSION_1_PRE_BETA_3       0x00000601
headers/os/BeBuild.h:#define B_HAIKU_VERSION_1_BETA_3           0x00000700
headers/os/BeBuild.h:#define B_HAIKU_VERSION_1_PRE_BETA_4       0x00000701
headers/os/BeBuild.h:#define B_HAIKU_VERSION_1_BETA_4           0x00000800
headers/os/BeBuild.h:#define B_HAIKU_VERSION_1_PRE_BETA_5       0x00000801
headers/os/BeBuild.h:#define B_HAIKU_VERSION_1                          0x00010000

This gives you easily comparable “API version” numbers, useful if you need a “newer than”/“older than” check. While the method used in AboutSystem gives you the human-readable name for the release.

			auto libbe = "/boot/system/lib/";
			image_info info;
			auto img = load_add_on(libbe);
			auto r = get_image_info(img, &info);
			printf("r=%i api_version=%x\n", r, info.api_version)

Gives me 0x10… which is none of the version #defs?

1 Like

I think there’s some bug there. The ABI version, however, should be correct IIRC.

So using that I’ve now got something working:

Scribe v3.2 (Haiku v1.4.56578, Debug, en)

Is “R1” and “Beta4” and “hrev56578”. Noice.

The Linux build for instance prints:

Scribe v3.2 (Linux v5.15.0, Debug, Gnome, en)

Where the version is from what kernel you’re running.

It seems dangerous to represent the version as such, for one there likely will be a 1.4 point release later on and for another the hrev numver you have is wrong.

On the betas this is always hrevXXXXX+NNN
where NNN is the number if additional commits after the hrev the veta was branced on.

and not the beos version.

Yes, R1 beta 4 is not the same as R1.4. And, maybe more immediately problematic, it is also very different from R1 alpha 4 which also exists. This is also why uname just says 1. These are all just development builds of Haiku version 1.

If you look at the B_HAIKU_VERSION_* constants and how their values are constructed, you can see that it is internally represented as “0.8.0”. Although I wouldn’t use that as an user facing version either, because no one will understand what it means.

1 Like

So it seems the is no straightforward way to get the system version. And no way to reliably represent it in traditional integer form. Maybe we could come up with a better way for the future?

The canonical way to represent the Haiku version in a single string is the one used in Haiku package names (e.g. R1~beta4... etc.)