> In any case, the documentation has in some sense misled you. __GNUC__
> is indeed defined by the compiler proper, not by the preprocessor.
> But that in turn does not matter, as if any non-gcc compiler *did* use
> the gcc preprocessor, it would do so via gcc -E. 

> Googling "Intel C++ __GNUC__" shows several major projects have been
> affected by this icc misfeature.

Upon further checking the GNU CPP Manual, some interesting things are revealed.
The current manual 
(http://gcc.gnu.org/onlinedocs/cpp/Common-Predefined-Macros.html#Common-Predefined-Macros)
 (version unspecified) says: 
__GNUC__
__GNUC_MINOR__
__GNUC_PATCHLEVEL__
These macros are defined by all GNU compilers that use the C preprocessor: C, 
C++, Objective-C and Fortran. ... These macros are also defined if you invoke 
the preprocessor directly.  ... If all you need to know is whether or not your 
program is being compiled by GCC, or a non-GCC compiler that claims to accept 
the GNU C dialects, you can simply test __GNUC__. 
Therefore, Intel C++ Compiler's definition of __GNUC__ appears to be legitimate 
if Intel honestly makes a reasonable claim that its compiler accepts the GNU C 
dialects.
In comparison, the GNU CPP 2.8.1 (1997) Manual 
(http://sunsite.ualberta.ca/Documentation/Gnu/gcc-2.8.1/html_node/cpp_13.html#SEC14)
  says:
__GNUC__ 
This macro is defined if and only if this is GNU C. This macro is defined only 
when the entire GNU C compiler is in use; if you invoke the preprocessor 
directly, `__GNUC__' is undefined. 
It seems this 1997 definition is more strict: a non-GCC compiler should never 
define __GNUC__.  In other words, in 1997, __GNUC__ can be used to uniquely 
identify the GNU C compiler, now it can't; and nothing can.  
On the other hand, the 1997 sentence "if you invoke the preprocessor directly, 
`__GNUC__' is undefined" is now replaced by "These macros are also defined if 
you invoke the preprocessor directly."  I have not had the time to find out 
what "invoke the preprocessor directly" means ('gcc -E' ?) but now the 
implication is that a non-'GNU C'-compliant compiler that uses GNU CPP as its 
preprocessor would have __GNUC__ defined, unless it takes the extra effort to 
somehow undefine it.
And this also raises an interesting question: "These macros are also defined if 
you invoke the preprocessor directly" seems to imply that __GNUC__ is defined 
by the preprocessor, not the compiler proper.  This appears to contradict the 
claim in a previous post (see above quote) that "__GNUC__ is indeed defined by 
the compiler proper, not by the preprocessor."
_________________________________________________________________
It’s a talkathon – but it’s not just talk.
http://www.imtalkathon.com/?source=EML_WLH_Talkathon_JustTalk

Reply via email to