Re: Feature request - a macro defined for GCC

Top Page

Reply to this message
Author: Jim Wilson
Date:  
To: x z
CC: gcc
Subject: Re: Feature request - a macro defined for GCC
x z wrote:
> I would like to see that GCC define a macro in the case it is being used to compile a program. Currently there is a __GNUC__ macro defined by the GNU C preprocessor CPP.


This is our mistake. Originally __GNUC__ meant that this was the GNU C
compiler (aka GNU Compiler Collection). However, we have added so many
extensions to the compiler that it later came to mean that this is the
GNU C language. There is unfortunately no way to distinguish between a
program written in GNU C, and a program intended to be compiled by the
GNU C compiler. All compilers that implement the GNU C language must
define __GNUC__. There is no way around this. The use of __GNUC__ is
so pervasive in GNU/Linux that a compiler has to define it or else it
simply won't work. This is why the Intel compilers and other compilers
define it. They have no choice.

If we want a solution to this problem, complaining to Intel and others
will do no good. We will have to fix it ourselves. One way to fix the
problem is to separate the meaning of the macros. We can have one macro
that means "this is a GNU C program" and other macro that means "this is
the GNU C compiler". We then have to make sure that glibc and other
libraries use the macros correctly. Etc.

While I agree that this is our mistake, it isn't clear to me why it
matters. If the Intel compiler correctly implements the GNU C language,
then it shouldn't matter if the code is being compiled by GCC or ICC.
Unless maybe you ran into a GCC bug, and want to enable a workaround
only for GCC.

Jim