Discussion:
[ast-developers] Linux kernel header version?
Irek Szczesniak
2013-08-09 19:37:29 UTC
Permalink
Does Linux have a cpp define which tells me the Linux kernel header version?

Irek
Michal Hlavinka
2013-08-12 11:39:49 UTC
Permalink
Post by Irek Szczesniak
Does Linux have a cpp define which tells me the Linux kernel header version?
Irek
Hi,

you can test kernel version this way:


#include <linux/version.h>

#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,16)
...
#endif

------
linux/version.h has this macro:

#define LINUX_VERSION_CODE 199171
#define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c))

Btw, I don't know why you need it, but compile time test is much better
than just version check as linux distributions usually patch kernel a lot.

Michal

Loading...