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.
6 .. index:: error messages, warnings vs errors, messages, warning and error
8 .. _warnings-and-errors:
10 Warning Messages and Error Messages
11 ***********************************
13 The GNU compiler can produce two kinds of diagnostics: errors and
14 warnings. Each kind has a different purpose:
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.
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
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
33 .. index:: pedantic, pedantic-errors
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
45 See :ref:`warning-options`, for
46 more detail on these and related command-line options.