Previous: Certain Changes We Don’t Want to Make, Up: Known Causes of Trouble with GCC [Contents][Index]
14.9 Warning Messages and Error Messages ¶
The GNU compiler can produce two kinds of diagnostics: errors andwarnings. Each kind has a different purpose:
- Errors report problems that make it impossible to compile yourprogram. GCC reports errors with the source file name and linenumber where the problem is apparent.
- Warnings report other unusual conditions in your code thatmay indicate a problem, although compilation can (and does)proceed. Warning messages also report the source file name and linenumber, but include the text ‘warning:’ to distinguish themfrom error messages.
Warnings may indicate danger points where you should check to make surethat your program really does what you intend; or the use of obsoletefeatures; or the use of nonstandard features of GNU C or C++. Manywarnings are issued only if you ask for them, with one of the -Woptions (for instance, -Wall requests a variety of usefulwarnings).
GCC always tries to compile your program if possible; it nevergratuitously rejects a program whose meaning is clear merely because(for instance) it fails to conform to a standard. In some cases,however, the C and C++ standards specify that certain extensions areforbidden, and a diagnostic must be issued by a conformingcompiler. The -pedantic option tells GCC to issue warnings insuch cases; -pedantic-errors says to make them errors instead.This does not mean that all non-ISO constructs get warningsor errors.
See Options to Request or Suppress Warnings, formore detail on these and related command-line options.