How to compile without warnings considered errors?

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

cc1: warnings being treated as errors 

This is now a large code base, and I don't like fixing all the warnings.

Can I compile successfully despite warnings?

+47
c gcc compiler-warnings
Jul 19 2018-12-12T00:
source share
6 answers

Thanks for all the helpful suggestions. Finally, I made sure there were no warnings in my code, but again received 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 
+1
Jul 20 2018-12-12T00:
source share
— -

Of course, find where -Werror set and remove this flag. Then the warnings will only be warnings.

+46
Jul 19 '12 at 12:52
source share

You can make all warnings handled as such using -Wno-error . You can make specific warnings as such using -Wno-error=<warning name> , where <warning name> is the name of the warning that you do not want to treat as an error.

If you want to completely disable all warnings, use -w (not recommended).




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

+19
Jul 19 2018-12-12T00:
source share

If you are compiling a Linux kernel. For example, if you want to disable a warning that is "unused-but-set-variable", it is considered an error. You can add an expression:

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

in the makefile

+3
Nov 24 '16 at 13:15
source share

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

+1
Aug 28 '16 at 19:22
source share

Remove -Werror from your Make or CMake files as suggested in this post

+1
Sep 29 '17 at 22:02
source share



All Articles