[c] 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?

This question is related to c gcc compiler-warnings

The answer is


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


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:

CFLAGS=-Wno-error ./configure

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


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


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


Examples related to c

conflicting types for 'outchar' Can't compile C program on a Mac after upgrade to Mojave Program to find largest and second largest number in array Prime numbers between 1 to 100 in C Programming Language In c, in bool, true == 1 and false == 0? How I can print to stderr in C? Visual Studio Code includePath "error: assignment to expression with array type error" when I assign a struct field (C) Compiling an application for use in highly radioactive environments How can you print multiple variables inside a string using printf?

Examples related to gcc

Can't compile C program on a Mac after upgrade to Mojave Compiling an application for use in highly radioactive environments Make Error 127 when running trying to compile code How to Install gcc 5.3 with yum on CentOS 7.2? How does one set up the Visual Studio Code compiler/debugger to GCC? How do I set up CLion to compile and run? CMake error at CMakeLists.txt:30 (project): No CMAKE_C_COMPILER could be found How to printf a 64-bit integer as hex? Differences between arm64 and aarch64 Fatal error: iostream: No such file or directory in compiling C program using GCC

Examples related to compiler-warnings

Property getters and setters error C2220: warning treated as error - no 'object' file generated Objective-C implicit conversion loses integer precision 'NSUInteger' (aka 'unsigned long') to 'int' warning How do you disable the unused variable warnings coming out of gcc in 3rd party code I do not wish to edit? What is "android:allowBackup"? Why this "Implicit declaration of function 'X'"? How to compile without warnings being treated as errors? warning: implicit declaration of function Multi-character constant warnings What does "control reaches end of non-void function" mean?