Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

gcc: how to not compile with warnings

Tags:

gcc

I would like to know if there is any gcc flag that doesn't compile to an object file, if there are warnings in the respective source file.

Thanks.

like image 431
nunos Avatar asked May 20 '10 01:05

nunos


People also ask

How do I turn off compiler warnings in GCC?

If the value of y is always 1, 2 or 3, then x is always initialized, but GCC doesn't know this. To suppress the warning, you need to provide a default case with assert(0) or similar code. This option also warns when a non-volatile automatic variable might be changed by a call to longjmp.

How do I compile without warnings?

You can make all warnings being treated as such using -Wno-error. You can make specific warnings being treated as such by using -Wno-error=<warning name> where <warning name> is the name of the warning you don't want treated as an error. If you want to entirely disable all warnings, use -w (not recommended).

Can compiler warnings be ignored?

Unlike compilation errors, warnings don't interrupt the compilation process. They are not errors from the viewpoint of a programming language, but they may be software bugs. However, many compilers can be customized so that their warnings don't stop the compilation process. Warnings must not be ignored.

Which option of GCC inhibit all warning messages?

Warn if variadic macros are used in pedantic ISO C90 mode, or the GNU alternate syntax when in pedantic ISO C99 mode. This is default. To inhibit the warning messages, use -Wno-variadic-macros . Warn if a register variable is declared volatile.


1 Answers

gcc -Werror: Make all warnings into errors.

like image 88
Brendan Long Avatar answered Sep 25 '22 20:09

Brendan Long