Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

gcc and clang warnings/errors flags

Tags:

gcc

clang

Where can I find a list of all available warning and error flags I can set in clang and gcc? I've looked all over both of their respective documentation sites, and I can't find anything.

like image 232
Heath Borders Avatar asked Dec 11 '11 18:12

Heath Borders


People also ask

What are different flags and options with GCC regarding warnings?

You can request many specific warnings with options beginning with ' -W ', for example -Wimplicit to request warnings on implicit declarations. Each of these specific warning options also has a negative form beginning ' -Wno- ' to turn off warnings; for example, -Wno-implicit .

What are the GCC flags?

Compiler flags are options you give to gcc when it compiles a file or set of files. You may provide these directly on the command line, or your development tools may generate them when they invoke gcc.

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 show all 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.


1 Answers

gcc --help=warnings,seperate
gcc --help=warnings,joined
gcc --help=warnings,undocumented
gcc --help=warnings

seperate flags are like boolean values; they are either on or off.
-Wflag means on. -Wno-flag means off.

joined flags are flags that require a value.
-Wflag=value

by typing gcc --help=warnings you will recieve all the warning options provided by your compiler.

EDIT:
looking at GNU Documentation, these warnings messages have existed since GCC 4.3.6

like image 136
Trevor Hickey Avatar answered Nov 01 '22 03:11

Trevor Hickey