22

What are these and what do they do?

  • -Wall
  • -W
  • -Werror

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?

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Mudit Kapoor
  • 351
  • 2
  • 3
  • 9

1 Answers1

41
  • -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

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
usr1234567
  • 21,601
  • 16
  • 108
  • 128