]> git.ipfire.org Git - thirdparty/gcc.git/blob - gcc/doc/gcc/known-causes-of-trouble-with-gcc/warning-messages-and-error-messages.rst
sphinx: add missing trailing newline
[thirdparty/gcc.git] / gcc / doc / gcc / known-causes-of-trouble-with-gcc / warning-messages-and-error-messages.rst
1 ..
2 Copyright 1988-2022 Free Software Foundation, Inc.
3 This is part of the GCC manual.
4 For copying conditions, see the copyright.rst file.
5
6 .. index:: error messages, warnings vs errors, messages, warning and error
7
8 .. _warnings-and-errors:
9
10 Warning Messages and Error Messages
11 ***********************************
12
13 The GNU compiler can produce two kinds of diagnostics: errors and
14 warnings. Each kind has a different purpose:
15
16 * :dfn:`Errors` report problems that make it impossible to compile your
17 program. GCC reports errors with the source file name and line
18 number where the problem is apparent.
19
20 * :dfn:`Warnings` report other unusual conditions in your code that
21 *may* indicate a problem, although compilation can (and does)
22 proceed. Warning messages also report the source file name and line
23 number, but include the text :samp:`warning:` to distinguish them
24 from error messages.
25
26 Warnings may indicate danger points where you should check to make sure
27 that your program really does what you intend; or the use of obsolete
28 features; or the use of nonstandard features of GNU C or C++. Many
29 warnings are issued only if you ask for them, with one of the :option:`-W`
30 options (for instance, :option:`-Wall` requests a variety of useful
31 warnings).
32
33 .. index:: pedantic, pedantic-errors
34
35 GCC always tries to compile your program if possible; it never
36 gratuitously rejects a program whose meaning is clear merely because
37 (for instance) it fails to conform to a standard. In some cases,
38 however, the C and C++ standards specify that certain extensions are
39 forbidden, and a diagnostic *must* be issued by a conforming
40 compiler. The :option:`-pedantic` option tells GCC to issue warnings in
41 such cases; :option:`-pedantic-errors` says to make them errors instead.
42 This does not mean that *all* non-ISO constructs get warnings
43 or errors.
44
45 See :ref:`warning-options`, for
46 more detail on these and related command-line options.