You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
130 lines
6.3 KiB
HTML
130 lines
6.3 KiB
HTML
<html lang="en">
|
|
<head>
|
|
<title>Obsolete Features - The C Preprocessor</title>
|
|
<meta http-equiv="Content-Type" content="text/html">
|
|
<meta name="description" content="The C Preprocessor">
|
|
<meta name="generator" content="makeinfo 4.13">
|
|
<link title="Top" rel="start" href="index.html#Top">
|
|
<link rel="up" href="Implementation-Details.html#Implementation-Details" title="Implementation Details">
|
|
<link rel="prev" href="Implementation-limits.html#Implementation-limits" title="Implementation limits">
|
|
<link rel="next" href="Differences-from-previous-versions.html#Differences-from-previous-versions" title="Differences from previous versions">
|
|
<link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage">
|
|
<!--
|
|
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.
|
|
-->
|
|
<meta http-equiv="Content-Style-Type" content="text/css">
|
|
<style type="text/css"><!--
|
|
pre.display { font-family:inherit }
|
|
pre.format { font-family:inherit }
|
|
pre.smalldisplay { font-family:inherit; font-size:smaller }
|
|
pre.smallformat { font-family:inherit; font-size:smaller }
|
|
pre.smallexample { font-size:smaller }
|
|
pre.smalllisp { font-size:smaller }
|
|
span.sc { font-variant:small-caps }
|
|
span.roman { font-family:serif; font-weight:normal; }
|
|
span.sansserif { font-family:sans-serif; font-weight:normal; }
|
|
--></style>
|
|
</head>
|
|
<body>
|
|
<div class="node">
|
|
<a name="Obsolete-Features"></a>
|
|
<p>
|
|
Next: <a rel="next" accesskey="n" href="Differences-from-previous-versions.html#Differences-from-previous-versions">Differences from previous versions</a>,
|
|
Previous: <a rel="previous" accesskey="p" href="Implementation-limits.html#Implementation-limits">Implementation limits</a>,
|
|
Up: <a rel="up" accesskey="u" href="Implementation-Details.html#Implementation-Details">Implementation Details</a>
|
|
<hr>
|
|
</div>
|
|
|
|
<h3 class="section">11.3 Obsolete Features</h3>
|
|
|
|
<p>CPP has some features which are present mainly for compatibility with
|
|
older programs. We discourage their use in new code. In some cases,
|
|
we plan to remove the feature in a future version of GCC.
|
|
|
|
<h4 class="subsection">11.3.1 Assertions</h4>
|
|
|
|
<p><a name="index-assertions-113"></a>
|
|
<dfn>Assertions</dfn> are a deprecated alternative to macros in writing
|
|
conditionals to test what sort of computer or system the compiled
|
|
program will run on. Assertions are usually predefined, but you can
|
|
define them with preprocessing directives or command-line options.
|
|
|
|
<p>Assertions were intended to provide a more systematic way to describe
|
|
the compiler's target system and we added them for compatibility with
|
|
existing compilers. In practice they are just as unpredictable as the
|
|
system-specific predefined macros. In addition, they are not part of
|
|
any standard, and only a few compilers support them.
|
|
Therefore, the use of assertions is <strong>less</strong> portable than the use
|
|
of system-specific predefined macros. We recommend you do not use them at
|
|
all.
|
|
|
|
<p><a name="index-predicates-114"></a>An assertion looks like this:
|
|
|
|
<pre class="smallexample"> #<var>predicate</var> (<var>answer</var>)
|
|
</pre>
|
|
<p class="noindent"><var>predicate</var> must be a single identifier. <var>answer</var> can be any
|
|
sequence of tokens; all characters are significant except for leading
|
|
and trailing whitespace, and differences in internal whitespace
|
|
sequences are ignored. (This is similar to the rules governing macro
|
|
redefinition.) Thus, <code>(x + y)</code> is different from <code>(x+y)</code> but
|
|
equivalent to <code>( x + y )<!-- /@w --></code>. Parentheses do not nest inside an
|
|
answer.
|
|
|
|
<p><a name="index-testing-predicates-115"></a>To test an assertion, you write it in an ‘<samp><span class="samp">#if</span></samp>’. For example, this
|
|
conditional succeeds if either <code>vax</code> or <code>ns16000</code> has been
|
|
asserted as an answer for <code>machine</code>.
|
|
|
|
<pre class="smallexample"> #if #machine (vax) || #machine (ns16000)
|
|
</pre>
|
|
<p class="noindent">You can test whether <em>any</em> answer is asserted for a predicate by
|
|
omitting the answer in the conditional:
|
|
|
|
<pre class="smallexample"> #if #machine
|
|
</pre>
|
|
<p><a name="index-g_t_0023assert-116"></a>Assertions are made with the ‘<samp><span class="samp">#assert</span></samp>’ directive. Its sole
|
|
argument is the assertion to make, without the leading ‘<samp><span class="samp">#</span></samp>’ that
|
|
identifies assertions in conditionals.
|
|
|
|
<pre class="smallexample"> #assert <var>predicate</var> (<var>answer</var>)
|
|
</pre>
|
|
<p class="noindent">You may make several assertions with the same predicate and different
|
|
answers. Subsequent assertions do not override previous ones for the
|
|
same predicate. All the answers for any given predicate are
|
|
simultaneously true.
|
|
|
|
<p><a name="index-assertions_002c-canceling-117"></a><a name="index-g_t_0023unassert-118"></a>Assertions can be canceled with the ‘<samp><span class="samp">#unassert</span></samp>’ directive. It
|
|
has the same syntax as ‘<samp><span class="samp">#assert</span></samp>’. In that form it cancels only the
|
|
answer which was specified on the ‘<samp><span class="samp">#unassert</span></samp>’ line; other answers
|
|
for that predicate remain true. You can cancel an entire predicate by
|
|
leaving out the answer:
|
|
|
|
<pre class="smallexample"> #unassert <var>predicate</var>
|
|
</pre>
|
|
<p class="noindent">In either form, if no such assertion has been made, ‘<samp><span class="samp">#unassert</span></samp>’ has
|
|
no effect.
|
|
|
|
<p>You can also make or cancel assertions using command-line options.
|
|
See <a href="Invocation.html#Invocation">Invocation</a>.
|
|
|
|
</body></html>
|
|
|