This is the mail archive of the
mailing list for the GCC project.
Re: Dealing with compilers that pretend to be GCC
- From: Duncan Sands <baldrick at free dot fr>
- To: gcc at gcc dot gnu dot org
- Date: Thu, 19 Jan 2012 15:32:39 +0100
- Subject: Re: Dealing with compilers that pretend to be GCC
- References: <email@example.com>
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.
this suggests that you shouldn't be testing for GCC, and instead should be
testing for support for particular features. For example, to know if nested
functions are supported you would have your configure script compile a mini
program that uses nested functions.
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
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.