Detect RIOt OS version

Hi,

Is there a nice convenient way to determine which version of RIOT OS I am using form within my application code? I’m hoping for a nice symbol like riot_version or some such :slightly_smiling_face:

I’ve noticed that the API changes occasionally and I’d like my code to be able to compile and run on multiple versions of the OS.

TIA,

Richard.

Hi,

The RIOT_VERSION macro contains this information:

It’s used in the RIOT boot for example:

I guess we could add something like Linux’ KERNEL_VERSION

#ifndef KERNEL_VERSION
#define KERNEL_VERSION(a, b, c) (((a) << 16) + ((b) << 8) + ((c) > 255 ? 255 : (c)))
#endif

and then

#define RIOT_VERSION_CODE KERNEL_VERSION(2021,7,0)

I opened a pull request to add the functionality.