Re: Compiler identification macro?

From: Russell Hanneken (rghanneken_at_pobox.com)
Date: 04/30/04


Date: Fri, 30 Apr 2004 03:03:59 GMT

Carl Ribbegaardh wrote:
> Is there any known list of compiler identification macros?
> I'm using VS 2003, g++ on windows, sun's cc and g++ on solaris. Is it
> possible to identify the compiler using macros?

It's possible, but exactly what macros you look for differs from system
to system. See, for example:

GCC: Common Predefined Macros (macros defined in every port of GCC)
http://gcc.gnu.org/onlinedocs/gcc-3.4.0/cpp/Common-Predefined-Macros.html#Common%20Predefined%20Macros

GCC: System-specific Predefined Macros (how to find system-specific GCC
macros)
http://gcc.gnu.org/onlinedocs/gcc-3.4.0/cpp/System-specific-Predefined-Macros.html#System-specific%20Predefined%20Macros

Microsoft: Predefined Macros
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vclang/html/_predir_predefined_macros.asp

I usually look for _MSC_VER to identify Microsoft compilers.

Since the answer to your question differs from system to system, you'll
have better luck seeking answers on newsgroups devoted to your
platform/compiler (assuming you can't find the answers in the
documentation).

Regards,

Russell Hanneken
rghanneken@pobox.com
Remove the 'g' from my address to send me mail.



Relevant Pages

  • Re: [lm-sensors] [PATCH 1/2] Create a DIV_ROUND_CLOSEST macro to do division with rounding
    ... cases where it cases gcc to generate worse code. ... Is it worth generating worse code for these simple macros? ... Perhaps it is only certain compiler versions. ... movzwl %ax, %eax ...
    (Linux-Kernel)
  • Re: Reflections on a classic Lisp Paper
    ... lisp dialects. ... user-defined special forms - Macros, Fexprs, and Nlambda. ... compilable because the compiler just couldn't do it. ...
    (comp.lang.lisp)
  • Re: Cpp Considered Harmful
    ... > However, in either case, assertions are invaluable in making certain ... because we now have our own cpp ... > macros, we can use several different compilers and have our system ... > built into the compiler. ...
    (comp.lang.cpp)
  • Re: Doing mini-languages in CL
    ... > Thats it in a nutshell. ... I think the detail to note is that the Macro facility is a Compiler ... simply put you may well be able to leverage CL macros in building your ...
    (comp.lang.lisp)
  • Re: Comparision of C Sharp and C performance
    ... You appear to be confusing C macros with conditional compilation. ... They are preprocessor directives. ... compiler permission to do constant folding in a visible way up front ...
    (comp.lang.c)