I am developing a BREW application. When compiling the application to get a MOD file, I am continuously getting this error:
cc1.exe: warnings being treated as errors
I want to disable this warning. I have googled it, and many say disabling -werror will help, but how can I do that?
The compiler is CodeSourcery ARM.
You need to remove -Werror from CFLAGS, CPPFLAGS etc.; these are usually set in Makefile's or build scripts.
However, I'd strongly advice to fix the actual warnings instead, which will produce more stable and error-free code.
Run this Command in Terminal to say, not to consider warning as error
make CFLAGS="-Wno-error=format-truncation"
Related
In the Build Settings is it possible to treat Specific warnings as Error instead of Treating all warnings are Errors.
This is a simple Switch statement checker in xcode :
GCC_WARN_CHECK_SWITCH_STATEMENTS = YES_Error
instead of :
GCC_WARN_CHECK_SWITCH_STATEMENTS = YES
But its not working for me.
Treat specific warnings as errors
use -Werror=
for example:
-Werror=unused-variable will treat unused variable as error, which originally treat as warning by -Wunused-variable flag
add these to Other Warning Flags in project setting.
Treat all warnings as errors except for some warnings
use -Werror and -Wno-error=
The first one will treat all warnings as errors, equals to the setting in Xcode.
And use -Wno-error= to make specific warning not be error. For example:
-Wno-error=unused-variable
add these to Other Warning Flags in project setting.
Reference https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html
For all warning flags https://clang.llvm.org/docs/DiagnosticsReference.html
This link may work for you.
http://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html says
-Wno-error=switch makes -Wswitch warnings not be errors, even when -Werror is in effect.
Please check.
When I run the make world command I got this error.
Anyone know what is causing this? I think it is related to my gcc version, but I could not upgrade it in debian. My gcc version is 4.7.2
numa.c: In function ‘acpi_parse_slit’:
numa.c:99:6: error: variable ‘localities’ set but not used [-Werror=unused-but-set- variable]
numa.c: In function ‘acpi_parse_srat’:
numa.c:152:26: error: variable ‘srat’ set bbut not used [-Werror=unused-but-set- variable]
It's caused by two variables being defined, set to a value, and then never used - the error messages pretty much say that... In addition, you have -Werror or one of its variants set, that turns what would normally be just a warning for a useless construct into an error, which causes the build to terminate.
Either remove the definitions of those two variables (probably not the best solution), or fix your build flags to get rid of the -Werror bits that escalate warnings into errors...
Try adding "KBUILD_CFLAGS += -Wno-error=unused-but-set-variable" to your Makefile(found in Xen root).
I'm trying to Cross compile a kernel for Android using Ubuntu.
After successfully setting up the menuconfig, and compiling with the following option:
make ARCH=arm CROSS_COMPILE="arm-bravo-" -i -j10
It starts building, but then terminates with a lot of these errors:
error: variable '*something*' set but not used [-Werror=unused-but-set-variable]
cc1: all warnings being treated as errors
Now I understand that this can be fixed by running gcc with --disable-werror option. Probem is that this is a huge project (kernel) and I am not well versed enough with make and Makefile, to know where I have to set this value. Kindly help me understand and fix this problem.
After weeks, I'm now in a position to answer my own question..
Look for KBUILD_CFLAGS in the main Makefile, and add the following to suppress warnings as errors:
KBUILD_CFLAGS += -w
// if all errors are to be suppressed
KBUILD_CFLAGS += -Wno-error=unused-but-set-variable
// if that specific error is to be suppressed.
I am trying to build a pass using llvm and I have finished building llvm and its associated components. However, when I run make after following all the steps to build a pass including the makefile, I get the following
relocation R_X86_64_32 against `a local symbol' can not be used when making a shared object; recompile with -fPIC
After tyring to find a fix by googling the error message, I came to know that this is not specific to llvm. A few solutions suggested that I should use "--enable-shared" while running configure but that didn't help my case. Now I want to re-build llvm using fPIC, as the error says. But how do I do this using the makefile?
Looks like you could add the -fPIC (for position-independent code, something you want for a shared library that could be loaded at any address) by setting shell variables:
export CFLAGS="$CFLAGS -fPIC"
export CXXFLAGS="$CXXFLAGS -fPIC"
Looking at Makefile.rules, these will be picked up and used. Seems strange that it wasn't there to begin with.
EDIT:
Actually, reading more in the makefiles, I found this link to the LLVM Makefile Guide. From Makefile.rules, setting either SHARED_LIBRARY=1 or LOADABLE_MODULE=1 (which implies SHARED_LIBRARY) in Makefile will put -fPIC in the compiler flags.
If you are moderately convinced that you should use '-fPIC' everywhere (or '-m32' or '-m64', which I need more frequently), then you can use the 'trick':
CC="gcc -fPIC" ./configure ...
This assumes a Bourne/Korn/POSIX/Bash shell and sets the environment variable CC to 'gcc -fPIC' before running the configure script. This (usually) ensures that all compilations are done with the specified flags. For setting the correct 'bittiness' of the compilation, this sometimes works better than the various other mechanisms you find - it is hard for a compilation to wriggle around it except by completely ignoring the fact you specified the C compiler to use.
Another option is to pass -fPIC directly to make in the following way:
make CFLAGS='-fPIC' CXXFLAGS='-fPIC'
I get this warning from GCC:
warning: cannot pass objects of non-POD type 'class Something' through '...'; call will abort at runtime
It's pretty deadly, especially since it calls an abort. Why isn't this an error? I would like to make it an error, but:
How do I make a specific warning an error?
Which warning is it? According to 3.8 Options to Request or Suppress Warnings, -Wno-invalid-offsetof, it looks like the flag to hide it, but it doesn't.
I'm not sure what the correct warning is, but once you've found it, you can change its disposition with the following (using 'format' as the example):
#pragma GCC diagnostic error "-Wformat"
Or as strager points out:
gcc -Werror=format ...
I've checked the gcc source for this and this specific warning cannot be disabled via command line flags.
-Werror=specific-warning will turn the specified -Wspecific-warning into an error in GCC 4.3.x or newer. In 4.1.2, only -Werror-implicit-function-declaration works. Note the hyphen instead of equals sign -- it works for that specific case only and no others. This is one of the more serious common warnings and it's definitely handy to make it into an error.
Apart from that, older versions of GCC only seem to provide the -Werror sledgehammer of making every last warning an error.
It sounds like there are a bunch of other warnings that you don't want to be turned into errors (using the -Werror flag). In general, it's good practice to fix all warnings. Using -Werror forces this.
You can use the -Werror compiler flag to turn all or some warnings into errors.
You can use -fdiagnostics-show-option to see the -W option that applies to a particular warning.
Unfortunately, in this case there isn't any specific option that covers that warning.
It appears that there will be better support for this in GCC 4.5.