[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Dealing with compilers that pretend to be GCC

From: Ludovic Courtès
Subject: Dealing with compilers that pretend to be GCC
Date: Thu, 19 Jan 2012 15:24:48 +0100
User-agent: Gnus/5.110018 (No Gnus v0.18) Emacs/24.0.90 (gnu/linux)


A number of compilers claim to be GCC, without actually being GCC.  This
has come to a point where they can hardly be distinguished–until one
actually tries to use them.

I had the following macro to determine whether plug-in support is


The macro is fairly elaborate.  Yet, ICC 12.0.1 and Clang 3.4 both pass
the test, because:

  - They support ‘--version’;

  - They define ‘__GNUC__’, which defeats Autoconf’s

  - They support ‘-print-file-name’, and have ‘-print-file-name=plugin’
    return GCC’s (!) plug-in header directory.  To that end, ICC simply
    runs ‘gcc -print-file-name=plugin’, while Clang appears to be doing
    some guesswork.

It turns out that ICC manages to build a working GCC plug-in, so after
all, it may be “entitled” to define ‘__GNUC__’, in a broad sense.

Conversely, Clang doesn’t support several GNU extensions, such as nested
functions, so it quickly fails to compile code.

Based on that, I modified my feature test like this:


I don’t see what can be done on “our” side (perhaps Autoconf’s feature
test could be strengthened, but how?), but I wanted to document this
state of affairs.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]