Compiler identification macro?

C

Carl Ribbegaardh

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?
I'm aware of WIN32 being defined, but that's defined on mingw g++ in windows
too.
Is it called compiler identification macros or is there another term I
should search for?

Thanks!
 
R

Russell Hanneken

Carl said:
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 Predefined Macros

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

Microsoft: Predefined Macros
http://msdn.microsoft.com/library/d...-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
(e-mail address removed)
Remove the 'g' from my address to send me mail.
 
W

Walter

Carl Ribbegaardh said:
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?
I'm aware of WIN32 being defined, but that's defined on mingw g++ in windows
too.
Is it called compiler identification macros or is there another term I
should search for?

These should be in the specific documentation for each compiler you are
using. For Digital Mars C++, the correct way to identify it is:

#ifdef __DMC__
// You're running the Digital Mars C++ compiler
#endif

Do not use WIN32, as that specifies the target operating system, and many
diverse compilers target WIN32.

-Walter
www.digitalmars.com free C/C++/D compilers
 
V

void

U¿ytkownik Carl Ribbegaardh napisa³, On 2004-04-30 02:45:
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?
I'm aware of WIN32 being defined, but that's defined on mingw g++ in windows
too.
Is it called compiler identification macros or is there another term I
should search for?


http://predef.sourceforge.net/precomp.html
Best
Darek
 
L

Leor Zolman

U¿ytkownik Carl Ribbegaardh napisa³, On 2004-04-30 02:45:


http://predef.sourceforge.net/precomp.html

Man, I sure wish I'd have known about that page when I was struggling with
this very issue when working on InitUtil. But that was before I'd begun
dabbling in newsgroups, and it never occurred to me I could just ask the
question! So great answer, and equally great question ;-)
-leor
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,564
Members
45,040
Latest member
papereejit

Latest Threads

Top