Saurabh Verma
Saurabh Verma

Reputation: 6738

How can I 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 a way I can compile successfully in spite of the warnings?

Upvotes: 143

Views: 325720

Answers (7)

Andrea Araldo
Andrea Araldo

Reputation: 1442

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

Upvotes: 19

Andy Zhang
Andy Zhang

Reputation: 51

If you are compiling the 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.

Upvotes: 5

Marlab
Marlab

Reputation: 51

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

Upvotes: 5

Saurabh Verma
Saurabh Verma

Reputation: 6738

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

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

which I fixed by adding the CFLAG -fno-strict-overflow.

Upvotes: 4

orlp
orlp

Reputation: 117926

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: 3.8 Options to Request or Suppress Warnings

Upvotes: 50

Daniel Fischer
Daniel Fischer

Reputation: 183978

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

Upvotes: 111

Zibri
Zibri

Reputation: 9857

Solution:

CFLAGS=-Wno-error ./configure

Upvotes: 28

Related Questions