Warnings and Errors (Using the GNU Compiler Collection (GCC)) (2024)

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.

Warnings and Errors (Using the GNU Compiler Collection (GCC)) (2024)
Top Articles
Latest Posts
Article information

Author: Madonna Wisozk

Last Updated:

Views: 5890

Rating: 4.8 / 5 (68 voted)

Reviews: 83% of readers found this page helpful

Author information

Name: Madonna Wisozk

Birthday: 2001-02-23

Address: 656 Gerhold Summit, Sidneyberg, FL 78179-2512

Phone: +6742282696652

Job: Customer Banking Liaison

Hobby: Flower arranging, Yo-yoing, Tai chi, Rowing, Macrame, Urban exploration, Knife making

Introduction: My name is Madonna Wisozk, I am a attractive, healthy, thoughtful, faithful, open, vivacious, zany person who loves writing and wants to share my knowledge and understanding with you.