I have a problem like i need to include a different header files depending on the linux kernel in a .cpp file. I have to check the linux kernel version and include the headerfile depending on that kernel. How can I do that?

I have ARCH variable in Makefile which gives me exactly the kernel version, can i make use of that?

I'm going to guess, though I've never done this myself, that you'd do that through preprocessor directives in your source code. I'm thinking it would look something like:

#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)
#include <whatever_header.h>
#else
#include <a_different_header.h>
#endif

Of course, you'll want to change the version in KERNEL_VERSION, but beyond that it should work.

Check out this post: kernel version in C preprocessor