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.
175 lines
7.5 KiB
HTML
175 lines
7.5 KiB
HTML
4 years ago
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||
|
<html>
|
||
|
<!-- Copyright (C) 1987-2018 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 6.4, http://www.gnu.org/software/texinfo/ -->
|
||
|
<head>
|
||
|
<title>Obsolete Features (The C Preprocessor)</title>
|
||
|
|
||
|
<meta name="description" content="Obsolete Features (The C Preprocessor)">
|
||
|
<meta name="keywords" content="Obsolete Features (The C Preprocessor)">
|
||
|
<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="Implementation-limits.html#Implementation-limits" rel="prev" title="Implementation limits">
|
||
|
<style type="text/css">
|
||
|
<!--
|
||
|
a.summary-letter {text-decoration: none}
|
||
|
blockquote.indentedblock {margin-right: 0em}
|
||
|
blockquote.smallindentedblock {margin-right: 0em; font-size: smaller}
|
||
|
blockquote.smallquotation {font-size: smaller}
|
||
|
div.display {margin-left: 3.2em}
|
||
|
div.example {margin-left: 3.2em}
|
||
|
div.lisp {margin-left: 3.2em}
|
||
|
div.smalldisplay {margin-left: 3.2em}
|
||
|
div.smallexample {margin-left: 3.2em}
|
||
|
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.nolinebreak {white-space: nowrap}
|
||
|
span.roman {font-family: initial; font-weight: normal}
|
||
|
span.sansserif {font-family: sans-serif; font-weight: normal}
|
||
|
ul.no-bullet {list-style: none}
|
||
|
-->
|
||
|
</style>
|
||
|
|
||
|
|
||
|
</head>
|
||
|
|
||
|
<body lang="en">
|
||
|
<a name="Obsolete-Features"></a>
|
||
|
<div class="header">
|
||
|
<p>
|
||
|
Previous: <a href="Implementation-limits.html#Implementation-limits" accesskey="p" rel="prev">Implementation limits</a>, Up: <a href="Implementation-Details.html#Implementation-Details" accesskey="u" rel="up">Implementation Details</a> [<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="Obsolete-Features-1"></a>
|
||
|
<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.
|
||
|
</p>
|
||
|
<a name="Assertions"></a>
|
||
|
<h4 class="subsection">11.3.1 Assertions</h4>
|
||
|
<a name="index-assertions"></a>
|
||
|
|
||
|
<p><em>Assertions</em> 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>
|
||
|
<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"></a>
|
||
|
<p>An assertion looks like this:
|
||
|
</p>
|
||
|
<div class="smallexample">
|
||
|
<pre class="smallexample">#<var>predicate</var> (<var>answer</var>)
|
||
|
</pre></div>
|
||
|
|
||
|
<p><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"></a>
|
||
|
<p>To test an assertion, you write it in an ‘<samp>#if</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>.
|
||
|
</p>
|
||
|
<div class="smallexample">
|
||
|
<pre class="smallexample">#if #machine (vax) || #machine (ns16000)
|
||
|
</pre></div>
|
||
|
|
||
|
<p>You can test whether <em>any</em> answer is asserted for a predicate by
|
||
|
omitting the answer in the conditional:
|
||
|
</p>
|
||
|
<div class="smallexample">
|
||
|
<pre class="smallexample">#if #machine
|
||
|
</pre></div>
|
||
|
|
||
|
<a name="index-_0023assert"></a>
|
||
|
<p>Assertions are made with the ‘<samp>#assert</samp>’ directive. Its sole
|
||
|
argument is the assertion to make, without the leading ‘<samp>#</samp>’ that
|
||
|
identifies assertions in conditionals.
|
||
|
</p>
|
||
|
<div class="smallexample">
|
||
|
<pre class="smallexample">#assert <var>predicate</var> (<var>answer</var>)
|
||
|
</pre></div>
|
||
|
|
||
|
<p>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"></a>
|
||
|
<a name="index-_0023unassert"></a>
|
||
|
<p>Assertions can be canceled with the ‘<samp>#unassert</samp>’ directive. It
|
||
|
has the same syntax as ‘<samp>#assert</samp>’. In that form it cancels only the
|
||
|
answer which was specified on the ‘<samp>#unassert</samp>’ line; other answers
|
||
|
for that predicate remain true. You can cancel an entire predicate by
|
||
|
leaving out the answer:
|
||
|
</p>
|
||
|
<div class="smallexample">
|
||
|
<pre class="smallexample">#unassert <var>predicate</var>
|
||
|
</pre></div>
|
||
|
|
||
|
<p>In either form, if no such assertion has been made, ‘<samp>#unassert</samp>’ has
|
||
|
no effect.
|
||
|
</p>
|
||
|
<p>You can also make or cancel assertions using command-line options.
|
||
|
See <a href="Invocation.html#Invocation">Invocation</a>.
|
||
|
</p>
|
||
|
<hr>
|
||
|
<div class="header">
|
||
|
<p>
|
||
|
Previous: <a href="Implementation-limits.html#Implementation-limits" accesskey="p" rel="prev">Implementation limits</a>, Up: <a href="Implementation-Details.html#Implementation-Details" accesskey="u" rel="up">Implementation Details</a> [<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>
|