By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,910 Members | 1,085 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,910 IT Pros & Developers. It's quick & easy.

Compiler identification macro?

P: n/a
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!
Jul 22 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
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....fined%20Macros

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

Microsoft: Predefined Macros
http://msdn.microsoft.com/library/de...ned_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
rg********@pobox.com
Remove the 'g' from my address to send me mail.
Jul 22 '05 #2

P: n/a

"Carl Ribbegaardh" <ca*********************@hotmail.com> wrote in message
news:c6************@ID-111741.news.uni-berlin.de...
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
Jul 22 '05 #3

P: n/a
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
--
Life sucks, but it's better than the alternative.
Jul 22 '05 #4

P: n/a
Thanks a lot for your help guys!! :-D
Jul 22 '05 #5

P: n/a
On Fri, 30 Apr 2004 10:18:33 +0200, void <chq@nie_spamuj.wp.pl> wrote:
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


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
Best
Darek


--
Leor Zolman --- BD Software --- www.bdsoft.com
On-Site Training in C/C++, Java, Perl and Unix
C++ users: download BD Software's free STL Error Message Decryptor at:
www.bdsoft.com/tools/stlfilt.html
Jul 22 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.