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


On 2012-01-19 15:58:22 +0100, Duncan Sands wrote:
> Hi Ludo, I didn't really get it.  Why do you want to know whether the compiler
> is GCC or not?  Presumably because you have several versions of your code,
> one version using GCC feature XYZ and the other not using XYZ.  If so, the
> logically correct (but maybe impractical) approach is to test if the compiler
> supports XYZ, and switch between the two code versions depending on that.
> For example if XYZ is "nested functions", do you have a version of your code
> that uses nested functions and another that does not?  If you don't have a
> version that works with compilers like clang that don't support nested
> functions, then why bother testing for nested function support?  You will
> discover the lack of nested function support when your code fails to compile.

I don't know whether Ludo can use this approach, but it not possible
when providing a header file for some library (e.g. MPFR's mpfr.h).

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)

-- 
Vincent Lefèvre <vincent@vinc17.net> - Web: <http://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <http://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)


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