Obsolete-Features.html 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  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-2017 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 5.2, http://www.gnu.org/software/texinfo/ -->
  18. <head>
  19. <title>The C Preprocessor: Obsolete Features</title>
  20. <meta name="description" content="The C Preprocessor: Obsolete Features">
  21. <meta name="keywords" content="The C Preprocessor: Obsolete Features">
  22. <meta name="resource-type" content="document">
  23. <meta name="distribution" content="global">
  24. <meta name="Generator" content="makeinfo">
  25. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  26. <link href="index.html#Top" rel="start" title="Top">
  27. <link href="Index-of-Directives.html#Index-of-Directives" 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#Implementation-Details" rel="up" title="Implementation Details">
  30. <link href="Invocation.html#Invocation" rel="next" title="Invocation">
  31. <link href="Implementation-limits.html#Implementation-limits" rel="prev" title="Implementation limits">
  32. <style type="text/css">
  33. <!--
  34. a.summary-letter {text-decoration: none}
  35. blockquote.smallquotation {font-size: smaller}
  36. div.display {margin-left: 3.2em}
  37. div.example {margin-left: 3.2em}
  38. div.indentedblock {margin-left: 3.2em}
  39. div.lisp {margin-left: 3.2em}
  40. div.smalldisplay {margin-left: 3.2em}
  41. div.smallexample {margin-left: 3.2em}
  42. div.smallindentedblock {margin-left: 3.2em; font-size: smaller}
  43. div.smalllisp {margin-left: 3.2em}
  44. kbd {font-style:oblique}
  45. pre.display {font-family: inherit}
  46. pre.format {font-family: inherit}
  47. pre.menu-comment {font-family: serif}
  48. pre.menu-preformatted {font-family: serif}
  49. pre.smalldisplay {font-family: inherit; font-size: smaller}
  50. pre.smallexample {font-size: smaller}
  51. pre.smallformat {font-family: inherit; font-size: smaller}
  52. pre.smalllisp {font-size: smaller}
  53. span.nocodebreak {white-space:nowrap}
  54. span.nolinebreak {white-space:nowrap}
  55. span.roman {font-family:serif; font-weight:normal}
  56. span.sansserif {font-family:sans-serif; font-weight:normal}
  57. ul.no-bullet {list-style: none}
  58. -->
  59. </style>
  60. </head>
  61. <body lang="en" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000">
  62. <a name="Obsolete-Features"></a>
  63. <div class="header">
  64. <p>
  65. 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>
  66. </div>
  67. <hr>
  68. <a name="Obsolete-Features-1"></a>
  69. <h3 class="section">11.3 Obsolete Features</h3>
  70. <p>CPP has some features which are present mainly for compatibility with
  71. older programs. We discourage their use in new code. In some cases,
  72. we plan to remove the feature in a future version of GCC.
  73. </p>
  74. <a name="Assertions"></a>
  75. <h4 class="subsection">11.3.1 Assertions</h4>
  76. <a name="index-assertions"></a>
  77. <p><em>Assertions</em> are a deprecated alternative to macros in writing
  78. conditionals to test what sort of computer or system the compiled
  79. program will run on. Assertions are usually predefined, but you can
  80. define them with preprocessing directives or command-line options.
  81. </p>
  82. <p>Assertions were intended to provide a more systematic way to describe
  83. the compiler&rsquo;s target system and we added them for compatibility with
  84. existing compilers. In practice they are just as unpredictable as the
  85. system-specific predefined macros. In addition, they are not part of
  86. any standard, and only a few compilers support them.
  87. Therefore, the use of assertions is <strong>less</strong> portable than the use
  88. of system-specific predefined macros. We recommend you do not use them at
  89. all.
  90. </p>
  91. <a name="index-predicates"></a>
  92. <p>An assertion looks like this:
  93. </p>
  94. <div class="smallexample">
  95. <pre class="smallexample">#<var>predicate</var> (<var>answer</var>)
  96. </pre></div>
  97. <p><var>predicate</var> must be a single identifier. <var>answer</var> can be any
  98. sequence of tokens; all characters are significant except for leading
  99. and trailing whitespace, and differences in internal whitespace
  100. sequences are ignored. (This is similar to the rules governing macro
  101. redefinition.) Thus, <code>(x + y)</code> is different from <code>(x+y)</code> but
  102. equivalent to <code>(&nbsp;x&nbsp;+&nbsp;y&nbsp;)<!-- /@w --></code>. Parentheses do not nest inside an
  103. answer.
  104. </p>
  105. <a name="index-testing-predicates"></a>
  106. <p>To test an assertion, you write it in an &lsquo;<samp>#if</samp>&rsquo;. For example, this
  107. conditional succeeds if either <code>vax</code> or <code>ns16000</code> has been
  108. asserted as an answer for <code>machine</code>.
  109. </p>
  110. <div class="smallexample">
  111. <pre class="smallexample">#if #machine (vax) || #machine (ns16000)
  112. </pre></div>
  113. <p>You can test whether <em>any</em> answer is asserted for a predicate by
  114. omitting the answer in the conditional:
  115. </p>
  116. <div class="smallexample">
  117. <pre class="smallexample">#if #machine
  118. </pre></div>
  119. <a name="index-_0023assert"></a>
  120. <p>Assertions are made with the &lsquo;<samp>#assert</samp>&rsquo; directive. Its sole
  121. argument is the assertion to make, without the leading &lsquo;<samp>#</samp>&rsquo; that
  122. identifies assertions in conditionals.
  123. </p>
  124. <div class="smallexample">
  125. <pre class="smallexample">#assert <var>predicate</var> (<var>answer</var>)
  126. </pre></div>
  127. <p>You may make several assertions with the same predicate and different
  128. answers. Subsequent assertions do not override previous ones for the
  129. same predicate. All the answers for any given predicate are
  130. simultaneously true.
  131. </p>
  132. <a name="index-assertions_002c-canceling"></a>
  133. <a name="index-_0023unassert"></a>
  134. <p>Assertions can be canceled with the &lsquo;<samp>#unassert</samp>&rsquo; directive. It
  135. has the same syntax as &lsquo;<samp>#assert</samp>&rsquo;. In that form it cancels only the
  136. answer which was specified on the &lsquo;<samp>#unassert</samp>&rsquo; line; other answers
  137. for that predicate remain true. You can cancel an entire predicate by
  138. leaving out the answer:
  139. </p>
  140. <div class="smallexample">
  141. <pre class="smallexample">#unassert <var>predicate</var>
  142. </pre></div>
  143. <p>In either form, if no such assertion has been made, &lsquo;<samp>#unassert</samp>&rsquo; has
  144. no effect.
  145. </p>
  146. <p>You can also make or cancel assertions using command-line options.
  147. See <a href="Invocation.html#Invocation">Invocation</a>.
  148. </p>
  149. <hr>
  150. <div class="header">
  151. <p>
  152. 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>
  153. </div>
  154. </body>
  155. </html>