You can use GCC-specific predefined macros. This will work on all platforms, but only under gcc. To get a list, run
Code:
touch /tmp/foo.h gcc -dH /tmp/foo.h
Incedentally, it's usually considered bad practice to use #ifdef unnecessarily like you have done. It would be more readable to write your example as:
Code:
if(X86) {
... /* Do something specific of x86 platform */
} else if (IA64) {
... /* Do something specific of IA64 platform */
}
if(LINUX) {
... /* Do something specific of Linux kernel */
} else if(BSD) {
... /* Do something specific of BSD kernel */
}
This generates the same code, but also has the advantage that the compiler will point out errors in code that isn't used.
As an alternative, you could use a makefile, and define some constants:
Code:
CCFLAGS=-DKERN=`uname -s` -DKERN_VER=`uname -v` -DKERN_REL=`uname -r`-DHARDWARE=`uname -m` -DPROC=`uname -p`-DPLATFORM=`uname -p` -DOS=`uname -o`
target : gcc $CCFLAGS src1.c src2.c src3.c
This will work on most (all?) POSIX systems, regardless of the compiler.