|
You have to compile your program separately for each platform, so you can just invent your own define and test it
e.g. compiling on Windows cl -DWIN32 fred.cpp
compiling on Linux gcc -Dlinux fred.cpp
etc.
On Unix/Linux make usually uses a variable called CFLAGS or CPPFLAGS and CC when doing compiles so you can sometimes have a makefile that works on multiple platforms
but still detects the OS - something like.
$(CC) $(CFLAGS) fred.cpp
I build my programs to run on everything from Windows CE and MS-DOS through to Windows and AIX, and find this technique works well.
|