Implementation_002ddefined-behavior.html 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  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>Implementation-defined behavior (The C Preprocessor)</title>
  21. <meta name="description" content="Implementation-defined behavior (The C Preprocessor)">
  22. <meta name="keywords" content="Implementation-defined behavior (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="Implementation-limits.html" rel="next" title="Implementation limits">
  31. <link href="Implementation-Details.html" rel="prev" title="Implementation Details">
  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="Implementation_002ddefined-behavior"></span><div class="header">
  53. <p>
  54. Next: <a href="Implementation-limits.html" accesskey="n" rel="next">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="Implementation_002ddefined-behavior-1"></span><h3 class="section">11.1 Implementation-defined behavior</h3>
  58. <span id="index-implementation_002ddefined-behavior"></span>
  59. <p>This is how CPP behaves in all the cases which the C standard
  60. describes as <em>implementation-defined</em>. This term means that the
  61. implementation is free to do what it likes, but must document its choice
  62. and stick to it.
  63. </p>
  64. <ul>
  65. <li> The mapping of physical source file multi-byte characters to the
  66. execution character set.
  67. <p>The input character set can be specified using the
  68. <samp>-finput-charset</samp> option, while the execution character set may
  69. be controlled using the <samp>-fexec-charset</samp> and
  70. <samp>-fwide-exec-charset</samp> options.
  71. </p>
  72. </li><li> Identifier characters.
  73. <span id="Identifier-characters"></span>
  74. <p>The C and C++ standards allow identifiers to be composed of &lsquo;<samp>_</samp>&rsquo;
  75. and the alphanumeric characters. C++ also allows universal character
  76. names. C99 and later C standards permit both universal character
  77. names and implementation-defined characters. In both C and C++ modes,
  78. GCC accepts in identifiers exactly those extended characters that
  79. correspond to universal character names permitted by the chosen
  80. standard.
  81. </p>
  82. <p>GCC allows the &lsquo;<samp>$</samp>&rsquo; character in identifiers as an extension for
  83. most targets. This is true regardless of the <samp>std=</samp> switch,
  84. since this extension cannot conflict with standards-conforming
  85. programs. When preprocessing assembler, however, dollars are not
  86. identifier characters by default.
  87. </p>
  88. <p>Currently the targets that by default do not permit &lsquo;<samp>$</samp>&rsquo; are AVR,
  89. IP2K, MMIX, MIPS Irix 3, ARM aout, and PowerPC targets for the AIX
  90. operating system.
  91. </p>
  92. <p>You can override the default with <samp>-fdollars-in-identifiers</samp> or
  93. <samp>-fno-dollars-in-identifiers</samp>. See <a href="Invocation.html#fdollars_002din_002didentifiers">fdollars-in-identifiers</a>.
  94. </p>
  95. </li><li> Non-empty sequences of whitespace characters.
  96. <p>In textual output, each whitespace sequence is collapsed to a single
  97. space. For aesthetic reasons, the first token on each non-directive
  98. line of output is preceded with sufficient spaces that it appears in the
  99. same column as it did in the original source file.
  100. </p>
  101. </li><li> The numeric value of character constants in preprocessor expressions.
  102. <p>The preprocessor and compiler interpret character constants in the
  103. same way; i.e. escape sequences such as &lsquo;<samp>\a</samp>&rsquo; are given the
  104. values they would have on the target machine.
  105. </p>
  106. <p>The compiler evaluates a multi-character character constant a character
  107. at a time, shifting the previous value left by the number of bits per
  108. target character, and then or-ing in the bit-pattern of the new
  109. character truncated to the width of a target character. The final
  110. bit-pattern is given type <code>int</code>, and is therefore signed,
  111. regardless of whether single characters are signed or not.
  112. If there are more
  113. characters in the constant than would fit in the target <code>int</code> the
  114. compiler issues a warning, and the excess leading characters are
  115. ignored.
  116. </p>
  117. <p>For example, <code>'ab'</code> for a target with an 8-bit <code>char</code> would be
  118. interpreted as &lsquo;<samp>(int)&nbsp;((unsigned&nbsp;char)&nbsp;'a'&nbsp;*&nbsp;256&nbsp;+&nbsp;(unsigned&nbsp;char)&nbsp;'b')</samp>&rsquo;<!-- /@w -->, and <code>'\234a'</code> as &lsquo;<samp>(int)&nbsp;((unsigned&nbsp;char)&nbsp;'\234'&nbsp;*&nbsp;256&nbsp;+&nbsp;(unsigned&nbsp;char)&nbsp;'a')</samp>&rsquo;<!-- /@w -->.
  119. </p>
  120. </li><li> Source file inclusion.
  121. <p>For a discussion on how the preprocessor locates header files,
  122. <a href="Include-Operation.html">Include Operation</a>.
  123. </p>
  124. </li><li> Interpretation of the filename resulting from a macro-expanded
  125. &lsquo;<samp>#include</samp>&rsquo; directive.
  126. <p>See <a href="Computed-Includes.html">Computed Includes</a>.
  127. </p>
  128. </li><li> Treatment of a &lsquo;<samp>#pragma</samp>&rsquo; directive that after macro-expansion
  129. results in a standard pragma.
  130. <p>No macro expansion occurs on any &lsquo;<samp>#pragma</samp>&rsquo; directive line, so the
  131. question does not arise.
  132. </p>
  133. <p>Note that GCC does not yet implement any of the standard
  134. pragmas.
  135. </p>
  136. </li></ul>
  137. <hr>
  138. <div class="header">
  139. <p>
  140. Next: <a href="Implementation-limits.html" accesskey="n" rel="next">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>
  141. </div>
  142. </body>
  143. </html>