Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Recommended gcc warning options for C [closed]

Other than -Wall what other warnings have people found useful?

http://gcc.gnu.org/onlinedocs/gcc-4.3.2/gcc/Warning-Options.html

like image 699
Sard Avatar asked Sep 30 '08 19:09

Sard


People also ask

Which option of GCC inhibit all warning messages?

If -Wfatal-errors is also specified, then -Wfatal-errors takes precedence over this option. Inhibit all warning messages. Make all warnings into errors.

How do I enable warnings in GCC?

GCC 4.3+ now has -Q --help=warnings , and you can even specify --help=warnings,C to just print out the C related warnings.

Which GCC flag is used to enable all compiler warnings?

gcc -Wall enables all compiler's warning messages. This option should always be used, in order to generate better code.

How do I make GCC warnings as errors?

You can use the -Werror compiler flag to turn all or some warnings into errors. Show activity on this post. You can use -fdiagnostics-show-option to see the -W option that applies to a particular warning. Unfortunately, in this case there isn't any specific option that covers that warning.


1 Answers

I routinely use:

    gcc -m64 -std=c99 -pedantic -Wall -Wshadow -Wpointer-arith -Wcast-qual \         -Wstrict-prototypes -Wmissing-prototypes 

This set catches a lot for people unused to it (people whose code I get to compile with those flags for the first time); it seldom gives me a problem (though -Wcast-qual is occasionally a nuisance).

like image 174
Jonathan Leffler Avatar answered Oct 06 '22 13:10

Jonathan Leffler