This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[patch, docs] PR19309
- From: Steven Bosscher <stevenb at suse dot de>
- To: gcc-patches at gcc dot gnu dot org
- Date: Thu, 10 Feb 2005 11:36:06 +0100
- Subject: [patch, docs] PR19309
- Organization: SUSE Labs
Hi,
The documentation of cpp says that the predefined macros __GNUC__,
__GNUC_MINOR__, and __GNUC_PATCHLEVEL__ "are defined only when the
entire compiler is in use; if you invoke the preprocessor directly,
they are not defined."
In reality, they are also defined if you call cpp directly. In the
PR audit trail, Neil said he considers this a doc bug, so the patch
at the end of this message corrects the documentation.
I've also added a line that says that __GNUC__ may be defined by
other compilers (icc unfortunately defines it, for example). For
the bug fix we only need the first hunk.
OK for mainline?
Gr.
Steven
PR documentation/19309
* doc/cpp.texi: The __GNUC__ and related predefined macros
are also defined for the "standalone" cpp.
Some non-GCC compilers may also define __GNUC__.
Index: doc/cpp.texi
===================================================================
RCS file: /cvs/gcc/gcc/gcc/doc/cpp.texi,v
retrieving revision 1.77
diff -u -3 -p -r1.77 cpp.texi
--- doc/cpp.texi 6 Feb 2005 20:20:56 -0000 1.77
+++ doc/cpp.texi 10 Feb 2005 10:30:00 -0000
@@ -1927,16 +1927,16 @@ These macros are defined by all GNU comp
preprocessor: C, C++, and Objective-C@. Their values are the major
version, minor version, and patch level of the compiler, as integer
constants. For example, GCC 3.2.1 will define @code{__GNUC__} to 3,
-@code{__GNUC_MINOR__} to 2, and @code{__GNUC_PATCHLEVEL__} to 1. They
-are defined only when the entire compiler is in use; if you invoke the
-preprocessor directly, they are not defined.
+@code{__GNUC_MINOR__} to 2, and @code{__GNUC_PATCHLEVEL__} to 1. These
+macros are also defined if you invoke the preprocessor directly.
@code{__GNUC_PATCHLEVEL__} is new to GCC 3.0; it is also present in the
widely-used development snapshots leading up to 3.0 (which identify
themselves as GCC 2.96 or 2.97, depending on which snapshot you have).
If all you need to know is whether or not your program is being compiled
-by GCC, you can simply test @code{__GNUC__}. If you need to write code
+by GCC, or a non-GCC compiler that claims to accept the GNU C dialects,
+you can simply test @code{__GNUC__}. If you need to write code
which depends on a specific version, you must be more careful. Each
time the minor version is increased, the patch level is reset to zero;
each time the major version is increased (which happens rarely), the