How to compile without warnings being treated as errors?

CGccCompiler Warnings

C Problem Overview


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?

C Solutions


Solution 1 - C

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

Solution 2 - C

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

Solution 3 - C

Solution:

CFLAGS=-Wno-error ./configure

Solution 4 - C

Remove -Werror from your Make or CMake files, as suggested [in this post][1]

[1]: https://stackoverflow.com/a/10248526/2110769 "in this post"

Solution 5 - C

-Wall and -Werror compiler options can cause it, please check if those are used in compiler settings.

Solution 6 - C

If you are compiling linux kernel. For example, if you want to disable the warning that is "unused-but-set-variable" been treated as error. You can add a statement:

KBUILD_CFLAGS += $(call cc-option,-Wno-error=unused-but-set-variable,)

in your Makefile

Solution 7 - C

Thanks for all the helpful suggestions. I finally made sure that there are no warnings in my code, but again was getting this warning from sqlite3:

Assuming signed overflow does not occur when assuming that (X - c) <= X is always true

which I fixed by adding the following CFLAG:

-fno-strict-overflow

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionSaurabh VermaView Question on Stackoverflow
Solution 1 - CDaniel FischerView Answer on Stackoverflow
Solution 2 - CorlpView Answer on Stackoverflow
Solution 3 - CZibriView Answer on Stackoverflow
Solution 4 - CAndrea AraldoView Answer on Stackoverflow
Solution 5 - CMarlabView Answer on Stackoverflow
Solution 6 - CAndy Zhang View Answer on Stackoverflow
Solution 7 - CSaurabh VermaView Answer on Stackoverflow