Mudit Kapoor
Mudit Kapoor

Reputation: 381

Meaning of the g++ flags "-Wall", " -W", and "-Werror"

What are these and what do they do?

I am using the terminal in Ubuntu to compile programs with this command:

g++ -Wall -W -Werror main.cpp -o exec

What is the explanation?

Upvotes: 25

Views: 36268

Answers (1)

usr1234567
usr1234567

Reputation: 23422

  • -Wall: enable a set of warning, but actually not all.
  • -W: enable extra warnings. It's advised to use -Wextra instead which has the same meaning
  • -Werror: every warning is treated as an error.

See GCC documentation: 3.8 Options to Request or Suppress Warnings

Upvotes: 49

Related Questions