Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to compile without warnings being treated as errors?

The problem is that the same code that compiles well on Windows, is unable to compile on Ubuntu. Every time I get this error:

cc1: warnings being treated as errors 

Now, it's big code base and I don't like fix all the warnings.

Is there any way I can compile successfully in spite of the warnings?

like image 952
Saurabh Verma Avatar asked Jul 19 '12 12:07

Saurabh Verma


People also ask

Should I treat warnings as errors?

Yes, even once in a while you will encounter the occasional warning you'd be better off leaving as a warning or even disabling completely. Those should be the exception to the rule, though. Here's some practical advise: at the start of a new project, start treating all warnings as errors, by default.

How do you ignore a warning in make?

Try make -k instead of just make . That will 'continue' rather than stop. Show activity on this post. As an alternative to diving into the build system, try setting -Wno-error in CFLAGS, which you should be able to do through the environment (or at configure time, if using the GNU build system).

Will warnings affect whether your code compiles?

Compilers emit both erorrs, which prevent your code from compiling at all, and warnings, which indicate a potential problem, but still let your code compile. (Unless you have ask the compiler to treat warnings as errors, such as with the -Werror flag to gcc).

How do I ignore warnings in CPP?

To disable a set of warnings for a given piece of code, you have to start with a “push” pre-processor instruction, then with a disabling instruction for each of the warning you want to suppress, and finish with a “pop” pre-processor instruction.


2 Answers

Sure, find where -Werror is set and remove that flag. Then warnings will be only warnings.

like image 173
Daniel Fischer Avatar answered Sep 21 '22 06:09

Daniel Fischer


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).


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

like image 39
orlp Avatar answered Sep 19 '22 06:09

orlp