Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get list of default GCC warnings

Tags:

gcc

warnings

I'd like to know if it's possible to get a list of warnings that are enabled in GCC when no -Wx or -W-no-x flags are specified? I need this because I've got 2 different GCC versions (namely 3.3 and 4.3) which react differently on the same code with the same compilation flags.

For example, 4.3 with no additional warning options throws a warning when signed-to-unsigned comparison occurs while 3.3 does only if -Wsign-compare flag. So, I'd like to figure out, which flags should I add to gcc-3.3 to force it to detect the same warnings 4.3 does by default.

For 4.3 I'd managed to get such list of warnings using gcc -Q --help=warnings | grep enabled, but 3.3 doesn't seems to provide such function. Does anybody know, how it can be done in any other way? Maybe the source file that defines warning states?

Regards, Marvin

like image 673
mrvn Avatar asked Aug 15 '12 13:08

mrvn


People also ask

How do I enable all warnings in GCC?

You can't. Turning on everything would include -Wdouble-promotion which is only relevant on CPUs with a 32-bit single-precision floating-point unit which implements float in hardware, but emulates double in software. Doing calculations as double would use the software emulation and be slower.

What is werror?

-Werror= Make the specified warning into an error. The specifier for a warning is appended; for example -Werror=switch turns the warnings controlled by -Wswitch into errors.

Which option can be used to display compiler warnings?

You can use a #pragma warning directive to control the level of warning that's reported at compile time in specific source files. Warning pragma directives in source code are unaffected by the /w option.

What does the werror flag do?

The "-Werror" compiler flag treats all warnings as build errors. By promoting all warnings to errors, it enforces the developers to ensure such build warnings that may otherwise go unnoticed or only loosely concerned about by developers to now treat it with priority given that it will interrupt the build process.


1 Answers

GCC command line options are usually defined in gcc/common.opt file. Try searching for `Warning' keyword in this file.

like image 102
kayrick Avatar answered Oct 28 '22 13:10

kayrick