@c @cropmarks
@c @finalout
+@include gcc-common.texi
+
@copying
@c man begin COPYRIGHT
Copyright @copyright{} 1987, 1989, 1991, 1992, 1993, 1994, 1995, 1996,
-1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004
+1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005
Free Software Foundation, Inc.
Permission is granted to copy, distribute and/or modify this document
@c man end
@end copying
-@macro gcctabopt{body}
-@code{\body\}
-@end macro
-
@c Create a separate index for command line options.
@defcodeindex op
@syncodeindex vr op
@titlepage
@title The C Preprocessor
-@subtitle Last revised April 2001
-@subtitle for GCC version 3
+@subtitle for GCC version @value{version-GCC}
@author Richard M. Stallman
@author Zachary Weinberg
@page
Mode}.
For clarity, unless noted otherwise, references to @samp{CPP} in this
-manual refer to GNU CPP.
+manual refer to GNU CPP@.
@c man end
@menu
converted to the execution character set, just like unescaped
characters.
+Unless the experimental @option{-fextended-identifiers} option is used,
GCC does not permit the use of characters outside the ASCII range, nor
-@samp{\u} and @samp{\U} escapes, in identifiers. We hope this will
-change eventually, but there are problems with the standard semantics
-of such ``extended identifiers'' which must be resolved through the
-ISO C and C++ committees first.
+@samp{\u} and @samp{\U} escapes, in identifiers. Even with that
+option, characters outside the ASCII range can only be specified with
+the @samp{\u} and @samp{\U} escapes, not used directly in identifiers.
@node Initial processing
@section Initial processing
preprocessor. @xref{C++ Named Operators}.
In the 1999 C standard, identifiers may contain letters which are not
-part of the ``basic source character set,'' at the implementation's
+part of the ``basic source character set'', at the implementation's
discretion (such as accented Latin letters, Greek letters, or Chinese
ideograms). This may be done with an extended character set, or the
-@samp{\u} and @samp{\U} escape sequences. GCC does not presently
-implement either feature in the preprocessor or the compiler.
+@samp{\u} and @samp{\U} escape sequences. The implementation of this
+feature in GCC is experimental; such characters are only accepted in
+the @samp{\u} and @samp{\U} forms and only if
+@option{-fextended-identifiers} is used.
As an extension, GCC treats @samp{$} as a letter. This is for
compatibility with some systems, such as VMS, where @samp{$} is commonly
@end smallexample
@cindex other tokens
-Any other single character is considered ``other.'' It is passed on to
+Any other single character is considered ``other''. It is passed on to
the preprocessor's output unmolested. The C compiler will almost
certainly reject source code containing ``other'' tokens. In ASCII, the
only other characters are @samp{@@}, @samp{$}, @samp{`}, and control
quote marks. Directories after @option{-I-} are searched for all
headers. Second, the directory containing the current file is not
searched for anything, unless it happens to be one of the directories
-named by an @option{-I} switch. @option{-I-} is deprecated, -iquote
+named by an @option{-I} switch. @option{-I-} is deprecated, @option{-iquote}
should be used instead.
@option{-I. -I-} is not the same as no @option{-I} options at all, and does
There is no way to solve this problem within the C standard, but you can
use the GNU extension @samp{#include_next}. It means, ``Include the
-@emph{next} file with this name.'' This directive works like
+@emph{next} file with this name''. This directive works like
@samp{#include} except in searching for the specified file: it starts
searching the list of header file directories @emph{after} the directory
in which the current file was found.
@smallexample
extern void foo(void);
-#define foo() /* optimized inline version */
+#define foo() /* @r{optimized inline version} */
@dots{}
foo();
funcptr = foo;
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
work correctly. You should not use these macros directly; instead, include
the appropriate headers.
+@item __DEPRECATED
+This macro is defined, with value 1, when compiling a C++ source file
+with warnings about deprecated constructs enabled. These warnings are
+enabled by default, but can be disabled with @option{-Wno-deprecated}.
+
+@item __EXCEPTIONS
+This macro is defined, with value 1, when compiling a C++ source file
+with exceptions enabled. If @option{-fno-exceptions} was used when
+compiling the file, then this macro will not be defined.
+
@item __USING_SJLJ_EXCEPTIONS__
This macro is defined, with value 1, if the compiler uses the old
mechanism based on @code{setjmp} and @code{longjmp} for exception
handling.
+@item __GXX_WEAK__
+This macro is defined when compiling a C++ source file. It has the
+value 1 if the compiler will use weak symbols, COMDAT sections, or
+other similar techniques to collapse symbols with ``vague linkage''
+that are defined in multiple translation units. If the compiler will
+not collapse such symbols, this macro is defined with value 0. In
+general, user code should not need to make use of this macro; the
+purpose of this macro is to ease implementation of the C++ runtime
+library provided with G++.
+
@item __NEXT_RUNTIME__
This macro is defined, with value 1, if (and only if) the NeXT runtime
-(as in @option{-fnext-runtime}) is in use for Objective-C. If the GNU
+(as in @option{-fnext-runtime}) is in use for Objective-C@. If the GNU
runtime is used, this macro is not defined, so that you can use this
macro to determine which runtime (NeXT or GNU) is being used.
These macros are defined, with value 1, if (and only if) the compilation
is for a target where @code{long int} and pointer both use 64-bits and
@code{int} uses 32-bit.
+
+@item __SSP__
+This macro is defined, with value 1, when @option{-fstack-protector} is in
+use.
+
+@item __SSP_ALL__
+This macro is defined, with value 2, when @option{-fstack-protector-all} is
+in use.
+
@end table
@node System-specific Predefined Macros
@smallexample
#define FOUR (2 + 2)
#define FOUR (2 + 2)
-#define FOUR (2 /* two */ + 2)
+#define FOUR (2 /* @r{two} */ + 2)
@end smallexample
@noindent
but these are not:
@chapter Other Directives
@findex #ident
+@findex #sccs
The @samp{#ident} directive takes one argument, a string constant. On
some systems, that string constant is copied into a special segment of
-the object file. On other systems, the directive is ignored.
+the object file. On other systems, the directive is ignored. The
+@samp{#sccs} directive is a synonym for @samp{#ident}.
-This directive is not part of the C standard, but it is not an official
-GNU extension either. We believe it came from System V@.
-
-@findex #sccs
-The @samp{#sccs} directive is recognized, because it appears in the
-header files of some systems. It is a very old, obscure, extension
-which we did not invent, and we have been unable to find any
-documentation of what it should do, so GCC simply ignores it.
+These directives are not part of the C standard, but they are not
+official GNU extensions either. What historical information we have
+been able to find, suggests they originated with System V@.
@cindex null directive
The @dfn{null directive} consists of a @samp{#} followed by a newline,
@smallexample
#define m This macro's fine and has an unmatched quote
"/* This is not a comment. */
-/* This is a comment. The following #include directive
- is ill-formed. */
+/* @r{This is a comment. The following #include directive
+ is ill-formed.} */
#include <stdio.h
@end smallexample
whitespace.
One consequence is that it is legitimate for the replacement text to
-contain an unmatched quote (@pxref{Traditional lexical analysis}). An
+contain an unmatched quote (@pxref{Traditional lexical analysis}). An
unclosed string or character constant continues into the text
following the macro call. Similarly, the text at the end of a macro's
expansion can run together with the text after the macro invocation to
@smallexample
#define str(x) "x"
-str(/* A comment */some text )
+str(/* @r{A comment} */some text )
@expansion{} "some text "
@end smallexample
The C and C++ standards allow identifiers to be composed of @samp{_}
and the alphanumeric characters. C++ and C99 also allow universal
-character names (not implemented in GCC), and C99 further permits
-implementation-defined characters.
+character names, and C99 further permits implementation-defined
+characters. GCC currently only permits universal character names if
+@option{-fextended-identifiers} is used, because the implementation of
+universal character names in identifiers is experimental.
GCC allows the @samp{$} character in identifiers as an extension for
most targets. This is true regardless of the @option{std=} switch,
character truncated to the width of a target character. The final
bit-pattern is given type @code{int}, and is therefore signed,
regardless of whether single characters are signed or not (a slight
-change from versions 3.1 and earlier of GCC). If there are more
+change from versions 3.1 and earlier of GCC)@. If there are more
characters in the constant than would fit in the target @code{int} the
compiler issues a warning, and the excess leading characters are
ignored.
-For example, 'ab' for a target with an 8-bit @code{char} would be
-interpreted as @w{(int) ((unsigned char) 'a' * 256 + (unsigned char)
-'b')}, and '\234a' as @w{(int) ((unsigned char) '\234' * 256 + (unsigned
-char) 'a')}.
+For example, @code{'ab'} for a target with an 8-bit @code{char} would be
+interpreted as @w{@samp{(int) ((unsigned char) 'a' * 256 + (unsigned char)
+'b')}}, and @code{'\234a'} as @w{@samp{(int) ((unsigned char) '\234' *
+256 + (unsigned char) 'a')}}.
@item Source file inclusion.
@item -I- deprecated
-This option has been deprecated in 3.5. @option{-iquote} is meant to
+This option has been deprecated in 4.0. @option{-iquote} is meant to
replace the need for this option.
@item Order of evaluation of @samp{#} and @samp{##} operators
@item @samp{#line} and @samp{#include}
The @samp{#line} directive used to change GCC's notion of the
-``directory containing the current file,'' used by @samp{#include} with
+``directory containing the current file'', used by @samp{#include} with
a double-quoted header file name. In 3.0 and later, it does not.
@xref{Line Control}, for further explanation.
except that the C compiler has different rules for specifying the output
file.
-@strong{Note:} Whether you use the preprocessor by way of @command{gcc}
+@emph{Note:} Whether you use the preprocessor by way of @command{gcc}
or @command{cpp}, the @dfn{compiler driver} is run first. This
program's purpose is to translate your command into invocations of the
programs that do the actual work. Their command line interfaces are