blob: bc715502762c13fe70ff5f9f42ad054c89a2bcfe [file] [log] [blame]
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<!-- Copyright (C) 1987-2015 Free Software Foundation, Inc.
Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.3 or
any later version published by the Free Software Foundation. A copy of
the license is included in the
section entitled "GNU Free Documentation License".
This manual contains no Invariant Sections. The Front-Cover Texts are
(a) (see below), and the Back-Cover Texts are (b) (see below).
(a) The FSF's Front-Cover Text is:
A GNU Manual
(b) The FSF's Back-Cover Text is:
You have freedom to copy and modify this GNU Manual, like GNU
software. Copies published by the Free Software Foundation raise
funds for GNU development. -->
<!-- Created by GNU Texinfo 5.2, http://www.gnu.org/software/texinfo/ -->
<head>
<title>The C Preprocessor: Differences from previous versions</title>
<meta name="description" content="The C Preprocessor: Differences from previous versions">
<meta name="keywords" content="The C Preprocessor: Differences from previous versions">
<meta name="resource-type" content="document">
<meta name="distribution" content="global">
<meta name="Generator" content="makeinfo">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link href="index.html#Top" rel="start" title="Top">
<link href="Index-of-Directives.html#Index-of-Directives" rel="index" title="Index of Directives">
<link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
<link href="Implementation-Details.html#Implementation-Details" rel="up" title="Implementation Details">
<link href="Invocation.html#Invocation" rel="next" title="Invocation">
<link href="Obsolete-Features.html#Obsolete-Features" rel="prev" title="Obsolete Features">
<style type="text/css">
<!--
a.summary-letter {text-decoration: none}
blockquote.smallquotation {font-size: smaller}
div.display {margin-left: 3.2em}
div.example {margin-left: 3.2em}
div.indentedblock {margin-left: 3.2em}
div.lisp {margin-left: 3.2em}
div.smalldisplay {margin-left: 3.2em}
div.smallexample {margin-left: 3.2em}
div.smallindentedblock {margin-left: 3.2em; font-size: smaller}
div.smalllisp {margin-left: 3.2em}
kbd {font-style:oblique}
pre.display {font-family: inherit}
pre.format {font-family: inherit}
pre.menu-comment {font-family: serif}
pre.menu-preformatted {font-family: serif}
pre.smalldisplay {font-family: inherit; font-size: smaller}
pre.smallexample {font-size: smaller}
pre.smallformat {font-family: inherit; font-size: smaller}
pre.smalllisp {font-size: smaller}
span.nocodebreak {white-space:nowrap}
span.nolinebreak {white-space:nowrap}
span.roman {font-family:serif; font-weight:normal}
span.sansserif {font-family:sans-serif; font-weight:normal}
ul.no-bullet {list-style: none}
-->
</style>
</head>
<body lang="en" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000">
<a name="Differences-from-previous-versions"></a>
<div class="header">
<p>
Previous: <a href="Obsolete-Features.html#Obsolete-Features" accesskey="p" rel="prev">Obsolete Features</a>, Up: <a href="Implementation-Details.html#Implementation-Details" accesskey="u" rel="up">Implementation Details</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Index-of-Directives.html#Index-of-Directives" title="Index" rel="index">Index</a>]</p>
</div>
<hr>
<a name="Differences-from-previous-versions-1"></a>
<h3 class="section">11.4 Differences from previous versions</h3>
<a name="index-differences-from-previous-versions"></a>
<p>This section details behavior which has changed from previous versions
of CPP. We do not plan to change it again in the near future, but
we do not promise not to, either.
</p>
<p>The &ldquo;previous versions&rdquo; discussed here are 2.95 and before. The
behavior of GCC 3.0 is mostly the same as the behavior of the widely
used 2.96 and 2.97 development snapshots. Where there are differences,
they generally represent bugs in the snapshots.
</p>
<ul>
<li> -I- deprecated
<p>This option has been deprecated in 4.0. <samp>-iquote</samp> is meant to
replace the need for this option.
</p>
</li><li> Order of evaluation of &lsquo;<samp>#</samp>&rsquo; and &lsquo;<samp>##</samp>&rsquo; operators
<p>The standard does not specify the order of evaluation of a chain of
&lsquo;<samp>##</samp>&rsquo; operators, nor whether &lsquo;<samp>#</samp>&rsquo; is evaluated before, after, or
at the same time as &lsquo;<samp>##</samp>&rsquo;. You should therefore not write any code
which depends on any specific ordering. It is possible to guarantee an
ordering, if you need one, by suitable use of nested macros.
</p>
<p>An example of where this might matter is pasting the arguments &lsquo;<samp>1</samp>&rsquo;,
&lsquo;<samp>e</samp>&rsquo; and &lsquo;<samp>-2</samp>&rsquo;. This would be fine for left-to-right pasting,
but right-to-left pasting would produce an invalid token &lsquo;<samp>e-2</samp>&rsquo;.
</p>
<p>GCC 3.0 evaluates &lsquo;<samp>#</samp>&rsquo; and &lsquo;<samp>##</samp>&rsquo; at the same time and strictly
left to right. Older versions evaluated all &lsquo;<samp>#</samp>&rsquo; operators first,
then all &lsquo;<samp>##</samp>&rsquo; operators, in an unreliable order.
</p>
</li><li> The form of whitespace between tokens in preprocessor output
<p>See <a href="Preprocessor-Output.html#Preprocessor-Output">Preprocessor Output</a>, for the current textual format. This is
also the format used by stringification. Normally, the preprocessor
communicates tokens directly to the compiler&rsquo;s parser, and whitespace
does not come up at all.
</p>
<p>Older versions of GCC preserved all whitespace provided by the user and
inserted lots more whitespace of their own, because they could not
accurately predict when extra spaces were needed to prevent accidental
token pasting.
</p>
</li><li> Optional argument when invoking rest argument macros
<p>As an extension, GCC permits you to omit the variable arguments entirely
when you use a variable argument macro. This is forbidden by the 1999 C
standard, and will provoke a pedantic warning with GCC 3.0. Previous
versions accepted it silently.
</p>
</li><li> &lsquo;<samp>##</samp>&rsquo; swallowing preceding text in rest argument macros
<p>Formerly, in a macro expansion, if &lsquo;<samp>##</samp>&rsquo; appeared before a variable
arguments parameter, and the set of tokens specified for that argument
in the macro invocation was empty, previous versions of CPP would
back up and remove the preceding sequence of non-whitespace characters
(<strong>not</strong> the preceding token). This extension is in direct
conflict with the 1999 C standard and has been drastically pared back.
</p>
<p>In the current version of the preprocessor, if &lsquo;<samp>##</samp>&rsquo; appears between
a comma and a variable arguments parameter, and the variable argument is
omitted entirely, the comma will be removed from the expansion. If the
variable argument is empty, or the token before &lsquo;<samp>##</samp>&rsquo; is not a
comma, then &lsquo;<samp>##</samp>&rsquo; behaves as a normal token paste.
</p>
</li><li> &lsquo;<samp>#line</samp>&rsquo; and &lsquo;<samp>#include</samp>&rsquo;
<p>The &lsquo;<samp>#line</samp>&rsquo; directive used to change GCC&rsquo;s notion of the
&ldquo;directory containing the current file&rdquo;, used by &lsquo;<samp>#include</samp>&rsquo; with
a double-quoted header file name. In 3.0 and later, it does not.
See <a href="Line-Control.html#Line-Control">Line Control</a>, for further explanation.
</p>
</li><li> Syntax of &lsquo;<samp>#line</samp>&rsquo;
<p>In GCC 2.95 and previous, the string constant argument to &lsquo;<samp>#line</samp>&rsquo;
was treated the same way as the argument to &lsquo;<samp>#include</samp>&rsquo;: backslash
escapes were not honored, and the string ended at the second &lsquo;<samp>&quot;</samp>&rsquo;.
This is not compliant with the C standard. In GCC 3.0, an attempt was
made to correct the behavior, so that the string was treated as a real
string constant, but it turned out to be buggy. In 3.1, the bugs have
been fixed. (We are not fixing the bugs in 3.0 because they affect
relatively few people and the fix is quite invasive.)
</p>
</li></ul>
<hr>
<div class="header">
<p>
Previous: <a href="Obsolete-Features.html#Obsolete-Features" accesskey="p" rel="prev">Obsolete Features</a>, Up: <a href="Implementation-Details.html#Implementation-Details" accesskey="u" rel="up">Implementation Details</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Index-of-Directives.html#Index-of-Directives" title="Index" rel="index">Index</a>]</p>
</div>
</body>
</html>