kernel version in C preprocessor

How do you read the kernel version in the C preprocessor? I’ve discovered a #include directive that needs to be removed only for newer kernel versions > 2.6.22.

#if ???
#include <net/if.h>
#endif

Thanks!

In the Makefile or similar create a symbol, say LINUX_2_6_23 that is set depending on the output of uname -r and then use -DLINUX_2_6_23 in the gcc call.

what we are talking about here is a kernel module right ?

if so:


#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,22)
#include <net/if.h>
#endif

otherwise, use what ken_yap says.