Obsolete-Features.html 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  2. <html>
  3. <!-- Copyright (C) 1987-2023 Free Software Foundation, Inc.
  4. Permission is granted to copy, distribute and/or modify this document
  5. under the terms of the GNU Free Documentation License, Version 1.3 or
  6. any later version published by the Free Software Foundation. A copy of
  7. the license is included in the
  8. section entitled "GNU Free Documentation License".
  9. This manual contains no Invariant Sections. The Front-Cover Texts are
  10. (a) (see below), and the Back-Cover Texts are (b) (see below).
  11. (a) The FSF's Front-Cover Text is:
  12. A GNU Manual
  13. (b) The FSF's Back-Cover Text is:
  14. You have freedom to copy and modify this GNU Manual, like GNU
  15. software. Copies published by the Free Software Foundation raise
  16. funds for GNU development. -->
  17. <!-- Created by GNU Texinfo 6.7, http://www.gnu.org/software/texinfo/ -->
  18. <head>
  19. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  20. <title>Obsolete Features (The C Preprocessor)</title>
  21. <meta name="description" content="Obsolete Features (The C Preprocessor)">
  22. <meta name="keywords" content="Obsolete Features (The C Preprocessor)">
  23. <meta name="resource-type" content="document">
  24. <meta name="distribution" content="global">
  25. <meta name="Generator" content="makeinfo">
  26. <link href="index.html" rel="start" title="Top">
  27. <link href="Index-of-Directives.html" rel="index" title="Index of Directives">
  28. <link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
  29. <link href="Implementation-Details.html" rel="up" title="Implementation Details">
  30. <link href="Invocation.html" rel="next" title="Invocation">
  31. <link href="Implementation-limits.html" rel="prev" title="Implementation limits">
  32. <style type="text/css">
  33. <!--
  34. a.summary-letter {text-decoration: none}
  35. blockquote.indentedblock {margin-right: 0em}
  36. div.display {margin-left: 3.2em}
  37. div.example {margin-left: 3.2em}
  38. div.lisp {margin-left: 3.2em}
  39. kbd {font-style: oblique}
  40. pre.display {font-family: inherit}
  41. pre.format {font-family: inherit}
  42. pre.menu-comment {font-family: serif}
  43. pre.menu-preformatted {font-family: serif}
  44. span.nolinebreak {white-space: nowrap}
  45. span.roman {font-family: initial; font-weight: normal}
  46. span.sansserif {font-family: sans-serif; font-weight: normal}
  47. ul.no-bullet {list-style: none}
  48. -->
  49. </style>
  50. </head>
  51. <body lang="en">
  52. <span id="Obsolete-Features"></span><div class="header">
  53. <p>
  54. Previous: <a href="Implementation-limits.html" accesskey="p" rel="prev">Implementation limits</a>, Up: <a href="Implementation-Details.html" 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" title="Index" rel="index">Index</a>]</p>
  55. </div>
  56. <hr>
  57. <span id="Obsolete-Features-1"></span><h3 class="section">11.3 Obsolete Features</h3>
  58. <p>CPP has some features which are present mainly for compatibility with
  59. older programs. We discourage their use in new code. In some cases,
  60. we plan to remove the feature in a future version of GCC.
  61. </p>
  62. <span id="Assertions"></span><h4 class="subsection">11.3.1 Assertions</h4>
  63. <span id="index-assertions"></span>
  64. <p><em>Assertions</em> are a deprecated alternative to macros in writing
  65. conditionals to test what sort of computer or system the compiled
  66. program will run on. Assertions are usually predefined, but you can
  67. define them with preprocessing directives or command-line options.
  68. </p>
  69. <p>Assertions were intended to provide a more systematic way to describe
  70. the compiler&rsquo;s target system and we added them for compatibility with
  71. existing compilers. In practice they are just as unpredictable as the
  72. system-specific predefined macros. In addition, they are not part of
  73. any standard, and only a few compilers support them.
  74. Therefore, the use of assertions is <strong>less</strong> portable than the use
  75. of system-specific predefined macros. We recommend you do not use them at
  76. all.
  77. </p>
  78. <span id="index-predicates"></span>
  79. <p>An assertion looks like this:
  80. </p>
  81. <div class="example">
  82. <pre class="example">#<var>predicate</var> (<var>answer</var>)
  83. </pre></div>
  84. <p><var>predicate</var> must be a single identifier. <var>answer</var> can be any
  85. sequence of tokens; all characters are significant except for leading
  86. and trailing whitespace, and differences in internal whitespace
  87. sequences are ignored. (This is similar to the rules governing macro
  88. redefinition.) Thus, <code>(x + y)</code> is different from <code>(x+y)</code> but
  89. equivalent to <code>(&nbsp;x&nbsp;+&nbsp;y&nbsp;)<!-- /@w --></code>. Parentheses do not nest inside an
  90. answer.
  91. </p>
  92. <span id="index-testing-predicates"></span>
  93. <p>To test an assertion, you write it in an &lsquo;<samp>#if</samp>&rsquo;. For example, this
  94. conditional succeeds if either <code>vax</code> or <code>ns16000</code> has been
  95. asserted as an answer for <code>machine</code>.
  96. </p>
  97. <div class="example">
  98. <pre class="example">#if #machine (vax) || #machine (ns16000)
  99. </pre></div>
  100. <p>You can test whether <em>any</em> answer is asserted for a predicate by
  101. omitting the answer in the conditional:
  102. </p>
  103. <div class="example">
  104. <pre class="example">#if #machine
  105. </pre></div>
  106. <span id="index-_0023assert"></span>
  107. <p>Assertions are made with the &lsquo;<samp>#assert</samp>&rsquo; directive. Its sole
  108. argument is the assertion to make, without the leading &lsquo;<samp>#</samp>&rsquo; that
  109. identifies assertions in conditionals.
  110. </p>
  111. <div class="example">
  112. <pre class="example">#assert <var>predicate</var> (<var>answer</var>)
  113. </pre></div>
  114. <p>You may make several assertions with the same predicate and different
  115. answers. Subsequent assertions do not override previous ones for the
  116. same predicate. All the answers for any given predicate are
  117. simultaneously true.
  118. </p>
  119. <span id="index-assertions_002c-canceling"></span>
  120. <span id="index-_0023unassert"></span>
  121. <p>Assertions can be canceled with the &lsquo;<samp>#unassert</samp>&rsquo; directive. It
  122. has the same syntax as &lsquo;<samp>#assert</samp>&rsquo;. In that form it cancels only the
  123. answer which was specified on the &lsquo;<samp>#unassert</samp>&rsquo; line; other answers
  124. for that predicate remain true. You can cancel an entire predicate by
  125. leaving out the answer:
  126. </p>
  127. <div class="example">
  128. <pre class="example">#unassert <var>predicate</var>
  129. </pre></div>
  130. <p>In either form, if no such assertion has been made, &lsquo;<samp>#unassert</samp>&rsquo; has
  131. no effect.
  132. </p>
  133. <p>You can also make or cancel assertions using command-line options.
  134. See <a href="Invocation.html">Invocation</a>.
  135. </p>
  136. <hr>
  137. <div class="header">
  138. <p>
  139. Previous: <a href="Implementation-limits.html" accesskey="p" rel="prev">Implementation limits</a>, Up: <a href="Implementation-Details.html" 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" title="Index" rel="index">Index</a>]</p>
  140. </div>
  141. </body>
  142. </html>