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”…
That’s one option, or you can use get_image_info, find libbe.so or libroot.so 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:
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/libbe.so";
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?
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.
EDIT: You probably want B_SYSTEM_LIB_DIRECTORY
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.
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?