Diagnostic-Message-Formatting-Options.html 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  2. <html>
  3. <!-- Copyright (C) 1988-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; with the
  7. Invariant Sections being "Funding Free Software", the Front-Cover
  8. Texts being (a) (see below), and with the Back-Cover Texts being (b)
  9. (see below). A copy of the license is included in the section entitled
  10. "GNU Free Documentation License".
  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>Using the GNU Compiler Collection (GCC): Diagnostic Message Formatting Options</title>
  20. <meta name="description" content="Using the GNU Compiler Collection (GCC): Diagnostic Message Formatting Options">
  21. <meta name="keywords" content="Using the GNU Compiler Collection (GCC): Diagnostic Message Formatting Options">
  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="Option-Index.html#Option-Index" rel="index" title="Option Index">
  28. <link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
  29. <link href="Invoking-GCC.html#Invoking-GCC" rel="up" title="Invoking GCC">
  30. <link href="Warning-Options.html#Warning-Options" rel="next" title="Warning Options">
  31. <link href="Objective_002dC-and-Objective_002dC_002b_002b-Dialect-Options.html#Objective_002dC-and-Objective_002dC_002b_002b-Dialect-Options" rel="prev" title="Objective-C and Objective-C++ Dialect Options">
  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="Diagnostic-Message-Formatting-Options"></a>
  63. <div class="header">
  64. <p>
  65. Next: <a href="Warning-Options.html#Warning-Options" accesskey="n" rel="next">Warning Options</a>, Previous: <a href="Objective_002dC-and-Objective_002dC_002b_002b-Dialect-Options.html#Objective_002dC-and-Objective_002dC_002b_002b-Dialect-Options" accesskey="p" rel="prev">Objective-C and Objective-C++ Dialect Options</a>, Up: <a href="Invoking-GCC.html#Invoking-GCC" accesskey="u" rel="up">Invoking GCC</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Option-Index.html#Option-Index" title="Index" rel="index">Index</a>]</p>
  66. </div>
  67. <hr>
  68. <a name="Options-to-Control-Diagnostic-Messages-Formatting"></a>
  69. <h3 class="section">3.7 Options to Control Diagnostic Messages Formatting</h3>
  70. <a name="index-options-to-control-diagnostics-formatting"></a>
  71. <a name="index-diagnostic-messages"></a>
  72. <a name="index-message-formatting"></a>
  73. <p>Traditionally, diagnostic messages have been formatted irrespective of
  74. the output device&rsquo;s aspect (e.g. its width, &hellip;). You can use the
  75. options described below
  76. to control the formatting algorithm for diagnostic messages,
  77. e.g. how many characters per line, how often source location
  78. information should be reported. Note that some language front ends may not
  79. honor these options.
  80. </p>
  81. <dl compact="compact">
  82. <dt><code>-fmessage-length=<var>n</var></code></dt>
  83. <dd><a name="index-fmessage_002dlength"></a>
  84. <p>Try to format error messages so that they fit on lines of about
  85. <var>n</var> characters. If <var>n</var> is zero, then no line-wrapping is
  86. done; each error message appears on a single line. This is the
  87. default for all front ends.
  88. </p>
  89. </dd>
  90. <dt><code>-fdiagnostics-show-location=once</code></dt>
  91. <dd><a name="index-fdiagnostics_002dshow_002dlocation"></a>
  92. <p>Only meaningful in line-wrapping mode. Instructs the diagnostic messages
  93. reporter to emit source location information <em>once</em>; that is, in
  94. case the message is too long to fit on a single physical line and has to
  95. be wrapped, the source location won&rsquo;t be emitted (as prefix) again,
  96. over and over, in subsequent continuation lines. This is the default
  97. behavior.
  98. </p>
  99. </dd>
  100. <dt><code>-fdiagnostics-show-location=every-line</code></dt>
  101. <dd><p>Only meaningful in line-wrapping mode. Instructs the diagnostic
  102. messages reporter to emit the same source location information (as
  103. prefix) for physical lines that result from the process of breaking
  104. a message which is too long to fit on a single line.
  105. </p>
  106. </dd>
  107. <dt><code>-fdiagnostics-color[=<var>WHEN</var>]</code></dt>
  108. <dt><code>-fno-diagnostics-color</code></dt>
  109. <dd><a name="index-fdiagnostics_002dcolor"></a>
  110. <a name="index-highlight_002c-color"></a>
  111. <a name="index-GCC_005fCOLORS-environment-variable"></a>
  112. <p>Use color in diagnostics. <var>WHEN</var> is &lsquo;<samp>never</samp>&rsquo;, &lsquo;<samp>always</samp>&rsquo;,
  113. or &lsquo;<samp>auto</samp>&rsquo;. The default depends on how the compiler has been configured,
  114. it can be any of the above <var>WHEN</var> options or also &lsquo;<samp>never</samp>&rsquo;
  115. if <code>GCC_COLORS</code> environment variable isn&rsquo;t present in the environment,
  116. and &lsquo;<samp>auto</samp>&rsquo; otherwise.
  117. &lsquo;<samp>auto</samp>&rsquo; means to use color only when the standard error is a terminal.
  118. The forms <samp>-fdiagnostics-color</samp> and <samp>-fno-diagnostics-color</samp> are
  119. aliases for <samp>-fdiagnostics-color=always</samp> and
  120. <samp>-fdiagnostics-color=never</samp>, respectively.
  121. </p>
  122. <p>The colors are defined by the environment variable <code>GCC_COLORS</code>.
  123. Its value is a colon-separated list of capabilities and Select Graphic
  124. Rendition (SGR) substrings. SGR commands are interpreted by the
  125. terminal or terminal emulator. (See the section in the documentation
  126. of your text terminal for permitted values and their meanings as
  127. character attributes.) These substring values are integers in decimal
  128. representation and can be concatenated with semicolons.
  129. Common values to concatenate include
  130. &lsquo;<samp>1</samp>&rsquo; for bold,
  131. &lsquo;<samp>4</samp>&rsquo; for underline,
  132. &lsquo;<samp>5</samp>&rsquo; for blink,
  133. &lsquo;<samp>7</samp>&rsquo; for inverse,
  134. &lsquo;<samp>39</samp>&rsquo; for default foreground color,
  135. &lsquo;<samp>30</samp>&rsquo; to &lsquo;<samp>37</samp>&rsquo; for foreground colors,
  136. &lsquo;<samp>90</samp>&rsquo; to &lsquo;<samp>97</samp>&rsquo; for 16-color mode foreground colors,
  137. &lsquo;<samp>38;5;0</samp>&rsquo; to &lsquo;<samp>38;5;255</samp>&rsquo;
  138. for 88-color and 256-color modes foreground colors,
  139. &lsquo;<samp>49</samp>&rsquo; for default background color,
  140. &lsquo;<samp>40</samp>&rsquo; to &lsquo;<samp>47</samp>&rsquo; for background colors,
  141. &lsquo;<samp>100</samp>&rsquo; to &lsquo;<samp>107</samp>&rsquo; for 16-color mode background colors,
  142. and &lsquo;<samp>48;5;0</samp>&rsquo; to &lsquo;<samp>48;5;255</samp>&rsquo;
  143. for 88-color and 256-color modes background colors.
  144. </p>
  145. <p>The default <code>GCC_COLORS</code> is
  146. </p><div class="smallexample">
  147. <pre class="smallexample">error=01;31:warning=01;35:note=01;36:range1=32:range2=34:locus=01:\
  148. quote=01:fixit-insert=32:fixit-delete=31:\
  149. diff-filename=01:diff-hunk=32:diff-delete=31:diff-insert=32
  150. </pre></div>
  151. <p>where &lsquo;<samp>01;31</samp>&rsquo; is bold red, &lsquo;<samp>01;35</samp>&rsquo; is bold magenta,
  152. &lsquo;<samp>01;36</samp>&rsquo; is bold cyan, &lsquo;<samp>32</samp>&rsquo; is green, &lsquo;<samp>34</samp>&rsquo; is blue,
  153. &lsquo;<samp>01</samp>&rsquo; is bold, and &lsquo;<samp>31</samp>&rsquo; is red.
  154. Setting <code>GCC_COLORS</code> to the empty string disables colors.
  155. Supported capabilities are as follows.
  156. </p>
  157. <dl compact="compact">
  158. <dt><code>error=</code></dt>
  159. <dd><a name="index-error-GCC_005fCOLORS-capability"></a>
  160. <p>SGR substring for error: markers.
  161. </p>
  162. </dd>
  163. <dt><code>warning=</code></dt>
  164. <dd><a name="index-warning-GCC_005fCOLORS-capability"></a>
  165. <p>SGR substring for warning: markers.
  166. </p>
  167. </dd>
  168. <dt><code>note=</code></dt>
  169. <dd><a name="index-note-GCC_005fCOLORS-capability"></a>
  170. <p>SGR substring for note: markers.
  171. </p>
  172. </dd>
  173. <dt><code>range1=</code></dt>
  174. <dd><a name="index-range1-GCC_005fCOLORS-capability"></a>
  175. <p>SGR substring for first additional range.
  176. </p>
  177. </dd>
  178. <dt><code>range2=</code></dt>
  179. <dd><a name="index-range2-GCC_005fCOLORS-capability"></a>
  180. <p>SGR substring for second additional range.
  181. </p>
  182. </dd>
  183. <dt><code>locus=</code></dt>
  184. <dd><a name="index-locus-GCC_005fCOLORS-capability"></a>
  185. <p>SGR substring for location information, &lsquo;<samp>file:line</samp>&rsquo; or
  186. &lsquo;<samp>file:line:column</samp>&rsquo; etc.
  187. </p>
  188. </dd>
  189. <dt><code>quote=</code></dt>
  190. <dd><a name="index-quote-GCC_005fCOLORS-capability"></a>
  191. <p>SGR substring for information printed within quotes.
  192. </p>
  193. </dd>
  194. <dt><code>fixit-insert=</code></dt>
  195. <dd><a name="index-fixit_002dinsert-GCC_005fCOLORS-capability"></a>
  196. <p>SGR substring for fix-it hints suggesting text to
  197. be inserted or replaced.
  198. </p>
  199. </dd>
  200. <dt><code>fixit-delete=</code></dt>
  201. <dd><a name="index-fixit_002ddelete-GCC_005fCOLORS-capability"></a>
  202. <p>SGR substring for fix-it hints suggesting text to
  203. be deleted.
  204. </p>
  205. </dd>
  206. <dt><code>diff-filename=</code></dt>
  207. <dd><a name="index-diff_002dfilename-GCC_005fCOLORS-capability"></a>
  208. <p>SGR substring for filename headers within generated patches.
  209. </p>
  210. </dd>
  211. <dt><code>diff-hunk=</code></dt>
  212. <dd><a name="index-diff_002dhunk-GCC_005fCOLORS-capability"></a>
  213. <p>SGR substring for the starts of hunks within generated patches.
  214. </p>
  215. </dd>
  216. <dt><code>diff-delete=</code></dt>
  217. <dd><a name="index-diff_002ddelete-GCC_005fCOLORS-capability"></a>
  218. <p>SGR substring for deleted lines within generated patches.
  219. </p>
  220. </dd>
  221. <dt><code>diff-insert=</code></dt>
  222. <dd><a name="index-diff_002dinsert-GCC_005fCOLORS-capability"></a>
  223. <p>SGR substring for inserted lines within generated patches.
  224. </p></dd>
  225. </dl>
  226. </dd>
  227. <dt><code>-fno-diagnostics-show-option</code></dt>
  228. <dd><a name="index-fno_002ddiagnostics_002dshow_002doption"></a>
  229. <a name="index-fdiagnostics_002dshow_002doption"></a>
  230. <p>By default, each diagnostic emitted includes text indicating the
  231. command-line option that directly controls the diagnostic (if such an
  232. option is known to the diagnostic machinery). Specifying the
  233. <samp>-fno-diagnostics-show-option</samp> flag suppresses that behavior.
  234. </p>
  235. </dd>
  236. <dt><code>-fno-diagnostics-show-caret</code></dt>
  237. <dd><a name="index-fno_002ddiagnostics_002dshow_002dcaret"></a>
  238. <a name="index-fdiagnostics_002dshow_002dcaret"></a>
  239. <p>By default, each diagnostic emitted includes the original source line
  240. and a caret &lsquo;<samp>^</samp>&rsquo; indicating the column. This option suppresses this
  241. information. The source line is truncated to <var>n</var> characters, if
  242. the <samp>-fmessage-length=n</samp> option is given. When the output is done
  243. to the terminal, the width is limited to the width given by the
  244. <code>COLUMNS</code> environment variable or, if not set, to the terminal width.
  245. </p>
  246. </dd>
  247. <dt><code>-fdiagnostics-parseable-fixits</code></dt>
  248. <dd><a name="index-fdiagnostics_002dparseable_002dfixits"></a>
  249. <p>Emit fix-it hints in a machine-parseable format, suitable for consumption
  250. by IDEs. For each fix-it, a line will be printed after the relevant
  251. diagnostic, starting with the string &ldquo;fix-it:&rdquo;. For example:
  252. </p>
  253. <div class="smallexample">
  254. <pre class="smallexample">fix-it:&quot;test.c&quot;:{45:3-45:21}:&quot;gtk_widget_show_all&quot;
  255. </pre></div>
  256. <p>The location is expressed as a half-open range, expressed as a count of
  257. bytes, starting at byte 1 for the initial column. In the above example,
  258. bytes 3 through 20 of line 45 of &ldquo;test.c&rdquo; are to be replaced with the
  259. given string:
  260. </p>
  261. <div class="smallexample">
  262. <pre class="smallexample">00000000011111111112222222222
  263. 12345678901234567890123456789
  264. gtk_widget_showall (dlg);
  265. ^^^^^^^^^^^^^^^^^^
  266. gtk_widget_show_all
  267. </pre></div>
  268. <p>The filename and replacement string escape backslash as &ldquo;\\&quot;, tab as &ldquo;\t&rdquo;,
  269. newline as &ldquo;\n&rdquo;, double quotes as &ldquo;\&quot;&rdquo;, non-printable characters as octal
  270. (e.g. vertical tab as &ldquo;\013&rdquo;).
  271. </p>
  272. <p>An empty replacement string indicates that the given range is to be removed.
  273. An empty range (e.g. &ldquo;45:3-45:3&rdquo;) indicates that the string is to
  274. be inserted at the given position.
  275. </p>
  276. </dd>
  277. <dt><code>-fdiagnostics-generate-patch</code></dt>
  278. <dd><a name="index-fdiagnostics_002dgenerate_002dpatch"></a>
  279. <p>Print fix-it hints to stderr in unified diff format, after any diagnostics
  280. are printed. For example:
  281. </p>
  282. <div class="smallexample">
  283. <pre class="smallexample">--- test.c
  284. +++ test.c
  285. @ -42,5 +42,5 @
  286. void show_cb(GtkDialog *dlg)
  287. {
  288. - gtk_widget_showall(dlg);
  289. + gtk_widget_show_all(dlg);
  290. }
  291. </pre></div>
  292. <p>The diff may or may not be colorized, following the same rules
  293. as for diagnostics (see <samp>-fdiagnostics-color</samp>).
  294. </p>
  295. </dd>
  296. <dt><code>-fno-show-column</code></dt>
  297. <dd><a name="index-fno_002dshow_002dcolumn"></a>
  298. <p>Do not print column numbers in diagnostics. This may be necessary if
  299. diagnostics are being scanned by a program that does not understand the
  300. column numbers, such as <code>dejagnu</code>.
  301. </p>
  302. </dd>
  303. </dl>
  304. <hr>
  305. <div class="header">
  306. <p>
  307. Next: <a href="Warning-Options.html#Warning-Options" accesskey="n" rel="next">Warning Options</a>, Previous: <a href="Objective_002dC-and-Objective_002dC_002b_002b-Dialect-Options.html#Objective_002dC-and-Objective_002dC_002b_002b-Dialect-Options" accesskey="p" rel="prev">Objective-C and Objective-C++ Dialect Options</a>, Up: <a href="Invoking-GCC.html#Invoking-GCC" accesskey="u" rel="up">Invoking GCC</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Option-Index.html#Option-Index" title="Index" rel="index">Index</a>]</p>
  308. </div>
  309. </body>
  310. </html>