compiler

how to identify the type of compiler used?
Most compilers will auto-define macros that identify themselves. You will have to look in the documentation for each compiler you want to identify.

For example, the GCC (gcc and g++) identify themselves with the macro __GNUC__.
http://gcc.gnu.org/onlinedocs/cpp/Common-Predefined-Macros.html

1
2
3
4
5
6
7
8
9
10
11
12
13
#include <iostream>
int main()

  std::cout <<
  #ifdef __GNUC__
    "You are compiling with g++"
  #else
    "You are NOT compiling with g++"
  #endif
  << endl;

  return 0;
  }


For Borland C++Builder it is __BORLANDC__
(You'll have to look at your borland docs.)

For Microsoft VC++ it is _MSC_VER. (Check this one last, as it may be defined by compilers using the Win32 API also...)
http://msdn.microsoft.com/en-us/library/b0084kay.aspx

Etc.

Hope this helps.
Topic archived. No new replies allowed.