You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
380 lines
16 KiB
HTML
380 lines
16 KiB
HTML
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
|
<html>
|
|
<!-- Copyright (C) 1988-2018 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; with the
|
|
Invariant Sections being "Funding Free Software", the Front-Cover
|
|
Texts being (a) (see below), and with the Back-Cover Texts being (b)
|
|
(see below). A copy of the license is included in the section entitled
|
|
"GNU Free Documentation License".
|
|
|
|
(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 6.4, http://www.gnu.org/software/texinfo/ -->
|
|
<head>
|
|
<title>Diagnostic Message Formatting Options (Using the GNU Compiler Collection (GCC))</title>
|
|
|
|
<meta name="description" content="Diagnostic Message Formatting Options (Using the GNU Compiler Collection (GCC))">
|
|
<meta name="keywords" content="Diagnostic Message Formatting Options (Using the GNU Compiler Collection (GCC))">
|
|
<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="Option-Index.html#Option-Index" rel="index" title="Option Index">
|
|
<link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
|
|
<link href="Invoking-GCC.html#Invoking-GCC" rel="up" title="Invoking GCC">
|
|
<link href="Warning-Options.html#Warning-Options" rel="next" title="Warning Options">
|
|
<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">
|
|
<style type="text/css">
|
|
<!--
|
|
a.summary-letter {text-decoration: none}
|
|
blockquote.indentedblock {margin-right: 0em}
|
|
blockquote.smallindentedblock {margin-right: 0em; font-size: smaller}
|
|
blockquote.smallquotation {font-size: smaller}
|
|
div.display {margin-left: 3.2em}
|
|
div.example {margin-left: 3.2em}
|
|
div.lisp {margin-left: 3.2em}
|
|
div.smalldisplay {margin-left: 3.2em}
|
|
div.smallexample {margin-left: 3.2em}
|
|
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.nolinebreak {white-space: nowrap}
|
|
span.roman {font-family: initial; font-weight: normal}
|
|
span.sansserif {font-family: sans-serif; font-weight: normal}
|
|
ul.no-bullet {list-style: none}
|
|
-->
|
|
</style>
|
|
|
|
|
|
</head>
|
|
|
|
<body lang="en">
|
|
<a name="Diagnostic-Message-Formatting-Options"></a>
|
|
<div class="header">
|
|
<p>
|
|
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> [<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>
|
|
</div>
|
|
<hr>
|
|
<a name="Options-to-Control-Diagnostic-Messages-Formatting"></a>
|
|
<h3 class="section">3.7 Options to Control Diagnostic Messages Formatting</h3>
|
|
<a name="index-options-to-control-diagnostics-formatting"></a>
|
|
<a name="index-diagnostic-messages"></a>
|
|
<a name="index-message-formatting"></a>
|
|
|
|
<p>Traditionally, diagnostic messages have been formatted irrespective of
|
|
the output device’s aspect (e.g. its width, …). You can use the
|
|
options described below
|
|
to control the formatting algorithm for diagnostic messages,
|
|
e.g. how many characters per line, how often source location
|
|
information should be reported. Note that some language front ends may not
|
|
honor these options.
|
|
</p>
|
|
<dl compact="compact">
|
|
<dt><code>-fmessage-length=<var>n</var></code></dt>
|
|
<dd><a name="index-fmessage_002dlength"></a>
|
|
<p>Try to format error messages so that they fit on lines of about
|
|
<var>n</var> characters. If <var>n</var> is zero, then no line-wrapping is
|
|
done; each error message appears on a single line. This is the
|
|
default for all front ends.
|
|
</p>
|
|
</dd>
|
|
<dt><code>-fdiagnostics-show-location=once</code></dt>
|
|
<dd><a name="index-fdiagnostics_002dshow_002dlocation"></a>
|
|
<p>Only meaningful in line-wrapping mode. Instructs the diagnostic messages
|
|
reporter to emit source location information <em>once</em>; that is, in
|
|
case the message is too long to fit on a single physical line and has to
|
|
be wrapped, the source location won’t be emitted (as prefix) again,
|
|
over and over, in subsequent continuation lines. This is the default
|
|
behavior.
|
|
</p>
|
|
</dd>
|
|
<dt><code>-fdiagnostics-show-location=every-line</code></dt>
|
|
<dd><p>Only meaningful in line-wrapping mode. Instructs the diagnostic
|
|
messages reporter to emit the same source location information (as
|
|
prefix) for physical lines that result from the process of breaking
|
|
a message which is too long to fit on a single line.
|
|
</p>
|
|
</dd>
|
|
<dt><code>-fdiagnostics-color[=<var>WHEN</var>]</code></dt>
|
|
<dt><code>-fno-diagnostics-color</code></dt>
|
|
<dd><a name="index-fdiagnostics_002dcolor"></a>
|
|
<a name="index-highlight_002c-color"></a>
|
|
<a name="index-GCC_005fCOLORS-environment-variable"></a>
|
|
<p>Use color in diagnostics. <var>WHEN</var> is ‘<samp>never</samp>’, ‘<samp>always</samp>’,
|
|
or ‘<samp>auto</samp>’. The default depends on how the compiler has been configured,
|
|
it can be any of the above <var>WHEN</var> options or also ‘<samp>never</samp>’
|
|
if <code>GCC_COLORS</code> environment variable isn’t present in the environment,
|
|
and ‘<samp>auto</samp>’ otherwise.
|
|
‘<samp>auto</samp>’ means to use color only when the standard error is a terminal.
|
|
The forms <samp>-fdiagnostics-color</samp> and <samp>-fno-diagnostics-color</samp> are
|
|
aliases for <samp>-fdiagnostics-color=always</samp> and
|
|
<samp>-fdiagnostics-color=never</samp>, respectively.
|
|
</p>
|
|
<p>The colors are defined by the environment variable <code>GCC_COLORS</code>.
|
|
Its value is a colon-separated list of capabilities and Select Graphic
|
|
Rendition (SGR) substrings. SGR commands are interpreted by the
|
|
terminal or terminal emulator. (See the section in the documentation
|
|
of your text terminal for permitted values and their meanings as
|
|
character attributes.) These substring values are integers in decimal
|
|
representation and can be concatenated with semicolons.
|
|
Common values to concatenate include
|
|
‘<samp>1</samp>’ for bold,
|
|
‘<samp>4</samp>’ for underline,
|
|
‘<samp>5</samp>’ for blink,
|
|
‘<samp>7</samp>’ for inverse,
|
|
‘<samp>39</samp>’ for default foreground color,
|
|
‘<samp>30</samp>’ to ‘<samp>37</samp>’ for foreground colors,
|
|
‘<samp>90</samp>’ to ‘<samp>97</samp>’ for 16-color mode foreground colors,
|
|
‘<samp>38;5;0</samp>’ to ‘<samp>38;5;255</samp>’
|
|
for 88-color and 256-color modes foreground colors,
|
|
‘<samp>49</samp>’ for default background color,
|
|
‘<samp>40</samp>’ to ‘<samp>47</samp>’ for background colors,
|
|
‘<samp>100</samp>’ to ‘<samp>107</samp>’ for 16-color mode background colors,
|
|
and ‘<samp>48;5;0</samp>’ to ‘<samp>48;5;255</samp>’
|
|
for 88-color and 256-color modes background colors.
|
|
</p>
|
|
<p>The default <code>GCC_COLORS</code> is
|
|
</p><div class="smallexample">
|
|
<pre class="smallexample">error=01;31:warning=01;35:note=01;36:range1=32:range2=34:locus=01:\
|
|
quote=01:fixit-insert=32:fixit-delete=31:\
|
|
diff-filename=01:diff-hunk=32:diff-delete=31:diff-insert=32:\
|
|
type-diff=01;32
|
|
</pre></div>
|
|
<p>where ‘<samp>01;31</samp>’ is bold red, ‘<samp>01;35</samp>’ is bold magenta,
|
|
‘<samp>01;36</samp>’ is bold cyan, ‘<samp>32</samp>’ is green, ‘<samp>34</samp>’ is blue,
|
|
‘<samp>01</samp>’ is bold, and ‘<samp>31</samp>’ is red.
|
|
Setting <code>GCC_COLORS</code> to the empty string disables colors.
|
|
Supported capabilities are as follows.
|
|
</p>
|
|
<dl compact="compact">
|
|
<dt><code>error=</code></dt>
|
|
<dd><a name="index-error-GCC_005fCOLORS-capability"></a>
|
|
<p>SGR substring for error: markers.
|
|
</p>
|
|
</dd>
|
|
<dt><code>warning=</code></dt>
|
|
<dd><a name="index-warning-GCC_005fCOLORS-capability"></a>
|
|
<p>SGR substring for warning: markers.
|
|
</p>
|
|
</dd>
|
|
<dt><code>note=</code></dt>
|
|
<dd><a name="index-note-GCC_005fCOLORS-capability"></a>
|
|
<p>SGR substring for note: markers.
|
|
</p>
|
|
</dd>
|
|
<dt><code>range1=</code></dt>
|
|
<dd><a name="index-range1-GCC_005fCOLORS-capability"></a>
|
|
<p>SGR substring for first additional range.
|
|
</p>
|
|
</dd>
|
|
<dt><code>range2=</code></dt>
|
|
<dd><a name="index-range2-GCC_005fCOLORS-capability"></a>
|
|
<p>SGR substring for second additional range.
|
|
</p>
|
|
</dd>
|
|
<dt><code>locus=</code></dt>
|
|
<dd><a name="index-locus-GCC_005fCOLORS-capability"></a>
|
|
<p>SGR substring for location information, ‘<samp>file:line</samp>’ or
|
|
‘<samp>file:line:column</samp>’ etc.
|
|
</p>
|
|
</dd>
|
|
<dt><code>quote=</code></dt>
|
|
<dd><a name="index-quote-GCC_005fCOLORS-capability"></a>
|
|
<p>SGR substring for information printed within quotes.
|
|
</p>
|
|
</dd>
|
|
<dt><code>fixit-insert=</code></dt>
|
|
<dd><a name="index-fixit_002dinsert-GCC_005fCOLORS-capability"></a>
|
|
<p>SGR substring for fix-it hints suggesting text to
|
|
be inserted or replaced.
|
|
</p>
|
|
</dd>
|
|
<dt><code>fixit-delete=</code></dt>
|
|
<dd><a name="index-fixit_002ddelete-GCC_005fCOLORS-capability"></a>
|
|
<p>SGR substring for fix-it hints suggesting text to
|
|
be deleted.
|
|
</p>
|
|
</dd>
|
|
<dt><code>diff-filename=</code></dt>
|
|
<dd><a name="index-diff_002dfilename-GCC_005fCOLORS-capability"></a>
|
|
<p>SGR substring for filename headers within generated patches.
|
|
</p>
|
|
</dd>
|
|
<dt><code>diff-hunk=</code></dt>
|
|
<dd><a name="index-diff_002dhunk-GCC_005fCOLORS-capability"></a>
|
|
<p>SGR substring for the starts of hunks within generated patches.
|
|
</p>
|
|
</dd>
|
|
<dt><code>diff-delete=</code></dt>
|
|
<dd><a name="index-diff_002ddelete-GCC_005fCOLORS-capability"></a>
|
|
<p>SGR substring for deleted lines within generated patches.
|
|
</p>
|
|
</dd>
|
|
<dt><code>diff-insert=</code></dt>
|
|
<dd><a name="index-diff_002dinsert-GCC_005fCOLORS-capability"></a>
|
|
<p>SGR substring for inserted lines within generated patches.
|
|
</p>
|
|
</dd>
|
|
<dt><code>type-diff=</code></dt>
|
|
<dd><a name="index-type_002ddiff-GCC_005fCOLORS-capability"></a>
|
|
<p>SGR substring for highlighting mismatching types within template
|
|
arguments in the C++ frontend.
|
|
</p></dd>
|
|
</dl>
|
|
|
|
</dd>
|
|
<dt><code>-fno-diagnostics-show-option</code></dt>
|
|
<dd><a name="index-fno_002ddiagnostics_002dshow_002doption"></a>
|
|
<a name="index-fdiagnostics_002dshow_002doption"></a>
|
|
<p>By default, each diagnostic emitted includes text indicating the
|
|
command-line option that directly controls the diagnostic (if such an
|
|
option is known to the diagnostic machinery). Specifying the
|
|
<samp>-fno-diagnostics-show-option</samp> flag suppresses that behavior.
|
|
</p>
|
|
</dd>
|
|
<dt><code>-fno-diagnostics-show-caret</code></dt>
|
|
<dd><a name="index-fno_002ddiagnostics_002dshow_002dcaret"></a>
|
|
<a name="index-fdiagnostics_002dshow_002dcaret"></a>
|
|
<p>By default, each diagnostic emitted includes the original source line
|
|
and a caret ‘<samp>^</samp>’ indicating the column. This option suppresses this
|
|
information. The source line is truncated to <var>n</var> characters, if
|
|
the <samp>-fmessage-length=n</samp> option is given. When the output is done
|
|
to the terminal, the width is limited to the width given by the
|
|
<code>COLUMNS</code> environment variable or, if not set, to the terminal width.
|
|
</p>
|
|
</dd>
|
|
<dt><code>-fdiagnostics-parseable-fixits</code></dt>
|
|
<dd><a name="index-fdiagnostics_002dparseable_002dfixits"></a>
|
|
<p>Emit fix-it hints in a machine-parseable format, suitable for consumption
|
|
by IDEs. For each fix-it, a line will be printed after the relevant
|
|
diagnostic, starting with the string “fix-it:”. For example:
|
|
</p>
|
|
<div class="smallexample">
|
|
<pre class="smallexample">fix-it:"test.c":{45:3-45:21}:"gtk_widget_show_all"
|
|
</pre></div>
|
|
|
|
<p>The location is expressed as a half-open range, expressed as a count of
|
|
bytes, starting at byte 1 for the initial column. In the above example,
|
|
bytes 3 through 20 of line 45 of “test.c” are to be replaced with the
|
|
given string:
|
|
</p>
|
|
<div class="smallexample">
|
|
<pre class="smallexample">00000000011111111112222222222
|
|
12345678901234567890123456789
|
|
gtk_widget_showall (dlg);
|
|
^^^^^^^^^^^^^^^^^^
|
|
gtk_widget_show_all
|
|
</pre></div>
|
|
|
|
<p>The filename and replacement string escape backslash as “\\", tab as “\t”,
|
|
newline as “\n”, double quotes as “\"”, non-printable characters as octal
|
|
(e.g. vertical tab as “\013”).
|
|
</p>
|
|
<p>An empty replacement string indicates that the given range is to be removed.
|
|
An empty range (e.g. “45:3-45:3”) indicates that the string is to
|
|
be inserted at the given position.
|
|
</p>
|
|
</dd>
|
|
<dt><code>-fdiagnostics-generate-patch</code></dt>
|
|
<dd><a name="index-fdiagnostics_002dgenerate_002dpatch"></a>
|
|
<p>Print fix-it hints to stderr in unified diff format, after any diagnostics
|
|
are printed. For example:
|
|
</p>
|
|
<div class="smallexample">
|
|
<pre class="smallexample">--- test.c
|
|
+++ test.c
|
|
@ -42,5 +42,5 @
|
|
|
|
void show_cb(GtkDialog *dlg)
|
|
{
|
|
- gtk_widget_showall(dlg);
|
|
+ gtk_widget_show_all(dlg);
|
|
}
|
|
|
|
</pre></div>
|
|
|
|
<p>The diff may or may not be colorized, following the same rules
|
|
as for diagnostics (see <samp>-fdiagnostics-color</samp>).
|
|
</p>
|
|
</dd>
|
|
<dt><code>-fdiagnostics-show-template-tree</code></dt>
|
|
<dd><a name="index-fdiagnostics_002dshow_002dtemplate_002dtree"></a>
|
|
|
|
<p>In the C++ frontend, when printing diagnostics showing mismatching
|
|
template types, such as:
|
|
</p>
|
|
<div class="smallexample">
|
|
<pre class="smallexample"> could not convert 'std::map<int, std::vector<double> >()'
|
|
from 'map<[...],vector<double>>' to 'map<[...],vector<float>>
|
|
</pre></div>
|
|
|
|
<p>the <samp>-fdiagnostics-show-template-tree</samp> flag enables printing a
|
|
tree-like structure showing the common and differing parts of the types,
|
|
such as:
|
|
</p>
|
|
<div class="smallexample">
|
|
<pre class="smallexample"> map<
|
|
[...],
|
|
vector<
|
|
[double != float]>>
|
|
</pre></div>
|
|
|
|
<p>The parts that differ are highlighted with color (“double” and
|
|
“float” in this case).
|
|
</p>
|
|
</dd>
|
|
<dt><code>-fno-elide-type</code></dt>
|
|
<dd><a name="index-fno_002delide_002dtype"></a>
|
|
<a name="index-felide_002dtype"></a>
|
|
<p>By default when the C++ frontend prints diagnostics showing mismatching
|
|
template types, common parts of the types are printed as “[...]” to
|
|
simplify the error message. For example:
|
|
</p>
|
|
<div class="smallexample">
|
|
<pre class="smallexample"> could not convert 'std::map<int, std::vector<double> >()'
|
|
from 'map<[...],vector<double>>' to 'map<[...],vector<float>>
|
|
</pre></div>
|
|
|
|
<p>Specifying the <samp>-fno-elide-type</samp> flag suppresses that behavior.
|
|
This flag also affects the output of the
|
|
<samp>-fdiagnostics-show-template-tree</samp> flag.
|
|
</p>
|
|
</dd>
|
|
<dt><code>-fno-show-column</code></dt>
|
|
<dd><a name="index-fno_002dshow_002dcolumn"></a>
|
|
<p>Do not print column numbers in diagnostics. This may be necessary if
|
|
diagnostics are being scanned by a program that does not understand the
|
|
column numbers, such as <code>dejagnu</code>.
|
|
</p>
|
|
</dd>
|
|
</dl>
|
|
|
|
<hr>
|
|
<div class="header">
|
|
<p>
|
|
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> [<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>
|
|
</div>
|
|
|
|
|
|
|
|
</body>
|
|
</html>
|