This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Dealing with compilers that pretend to be GCC


Hi Ludo,

For ICC, one can test __ICC. For instance, here's what we have in mpfr.h
(for the use of __builtin_constant_p and __extension__ ({ ... })):

#if defined (__GNUC__)&& !defined(__ICC)&& !defined(__cplusplus)

Yeah, but itâs a shame that those compilers define __GNUC__ without supporting 100% of the GNU C extensions. With this approach, you would also need to add !defined for Clang, PGI, and probably others.

even GCC may not support 100% of the GCC extensions! For example, you can find hacked GCC's out there which disable nested function support by default (I think Apple did this). Even more problematic IMO than testing __GNUC__ is code that tests for particular versions of GCC. There are versions of GCC which have backported features from more recent GCC's (eg: GNAT from Ada Core Technologies is like this). I've seen this cause problems with code that includes different header files depending on the gcc version, since the compiler doesn't have the expected set of header files.

Ciao, Duncan.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]