The compiler will predefine some macros that you can detect to determine which compiler you are using.
For example, Microsoft Visual C++ is defining _MSC_VER to a value:
MSVC++ 9.0 _MSC_VER = 1500
MSVC++ 8.0 _MSC_VER = 1400
MSVC++ 7.1 _MSC_VER = 1310
MSVC++ 7.0 _MSC_VER = 1300
MSVC++ 6.0 _MSC_VER = 1200
MSVC++ 5.0 _MSC_VER = 1100
You should be able to make use of something like #ifdef _MSC_VER and #if _MSC_VER > 1400 or whatever your specific needs are.
You can also detect symbols like __WIN32__ to detect if you are in a Windows build environment. Some compilers will define __unix__ or __APPLE__ if your build environment is of that variety.
Or for gcc you can use something like this:
/* Test for GCC > 3.2.0 */
#if __GNUC__ > 3 || \
(__GNUC__ == 3 && (__GNUC_MINOR__ > 2 || \
(__GNUC_MINOR__ == 2 && __GNUC_PATCHLEVEL__ > 0))
You can also detect __STDC__ to see if you are using an ANSI C compiler.