blob: 6699181d573e92c55da3f597fd1bd5b86465c32a [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: Obsolete Features</title>
<meta name="description" content="The C Preprocessor: Obsolete Features">
<meta name="keywords" content="The C Preprocessor: Obsolete Features">
<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="Differences-from-previous-versions.html#Differences-from-previous-versions" rel="next" title="Differences from previous versions">
<link href="Implementation-limits.html#Implementation-limits" rel="prev" title="Implementation limits">
<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="Obsolete-Features"></a>
<div class="header">
<p>
Next: <a href="Differences-from-previous-versions.html#Differences-from-previous-versions" accesskey="n" rel="next">Differences from previous versions</a>, 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> &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="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&rsquo;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>(&nbsp;x&nbsp;+&nbsp;y&nbsp;)<!-- /@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 &lsquo;<samp>#if</samp>&rsquo;. 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 &lsquo;<samp>#assert</samp>&rsquo; directive. Its sole
argument is the assertion to make, without the leading &lsquo;<samp>#</samp>&rsquo; 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 &lsquo;<samp>#unassert</samp>&rsquo; directive. It
has the same syntax as &lsquo;<samp>#assert</samp>&rsquo;. In that form it cancels only the
answer which was specified on the &lsquo;<samp>#unassert</samp>&rsquo; 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, &lsquo;<samp>#unassert</samp>&rsquo; 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>
Next: <a href="Differences-from-previous-versions.html#Differences-from-previous-versions" accesskey="n" rel="next">Differences from previous versions</a>, 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> &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>