How to disable warnings when compiling C code? - c

I am working on 32-bit Fedora 14 system. I'm compiling my source code using gcc.
Does anybody know how to disable warnings while compiling c code?
EDIT: Yes i know. Best thing is to fix those Warnings to avoid any undefined/unknown behavior. But currently here, i have written huge code first time and there are lots of error & warning in first compilation. Here i just want to concentrate on errors first and then i will see warnings.

try to add -w option when compiling
http://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html

Every body tells use -Wall switch with gcc, but you want to disable it. It is not advised, Use debugger to find it.
Linus Torvalds:
"But it clearly is the only right way. The fact that everybody else does it some other way only means that they are wrong"

The best is to find the problem. It will prevent you in future looking for errors, which would not have occured, if you fixed the actual one.
But, if you're sure there is no bug or you have assured the problem is caught by your code, place this somewhere in the file (where 177 the number of your warning is):
#pragma diag_suppress 177 // supress #177-D function was declared but never referenced

let say you are getting warning -Wfoo-bar try to add compilation flag -Wno-foo-bar

Related

Examples of 'falign-loops' optimisation occuring?

One pass run by the compiler when optimising in gcc is falign-loops.
Although a vague description is provided here: https://www.intel.com/content/www/us/en/develop/documentation/cpp-compiler-developer-guide-and-reference/top/compiler-reference/compiler-options/compiler-option-details/data-options/falign-loops-qalign-loops.html
It is listed as one of the optimisations occurring with the -O2 flag here:
https://gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html
I have been unable to actually see it work in action with any piece of code I have tried using compiler explorer. Does anyone know how the flag functions and perhaps have some explicit examples?
Thanks

IOCCC Program compiling errors

code: http://www.ioccc.org/1988/phillipps.c
How do i run this on Coderunner?
I've encountered some compiling problems that i can't solve after searching on the internet.Can someone help me out?
If I am not being informative enough, i'm sorry, but please tell me how i can do better at asking these tech questions.
compiling errors below(i use coderunner)
The program is written in an old dialect of C and is relying on some features now considered broken. Clang (the compiler in question) is not happy about the third argument of main and I don't think you can convince it to accept that.
You can either install gcc, that compiler will accept the code with just warnings. But I don't think coderunner has gcc integration.
Or you can manually unscrew the objectionable bit of the code.
Replace all instances of the word main with mayn in the code and add this bit of code to the beginning of the file:
main() {
mayn(1,0,0);
}
Now you can enjoy the program under clang/coderunner as well.

Break for C compilation

I am new to C. I encountered an error message which involves unexpected "}". However, I checked the number of "}" with an editor and indeed they pair up.
Then I wonder if there is a compiler command, so the compilation can stop whatever I want? It will be convenient to have such tool as debug help.
Thank you.
(Edited in 29-10-2015)
I typically write my code with gedit. Nonetheless, since my work is mostly done on cluster, it will be troublesome to transport the files up and down. I must turn to nano, vi or vim which causes difficulty in debugging.
Stopping compilation partway through is rarely a useful feature. You'll want to see all of the errors that may exist in your code so you can fix more that just one at a time.
That said, an error such as a misplaced brace or parenthesis can cascade down and cause several more errors to appear. So if you see a long list of errors that don't seem to make sense when you look at the code, start at the top and fix that, then recompile to see if it took care of any others.
The answer is no compilers are all or nothing.
However, a good editor is recommended. For example, you can match brackets with the % command in vi, or if you have a color editor, you can visually see what's going on. A better IDE would even allow you to hide/show blocks of code, format it with proper indentation, and flag any compilation issues from static rules without actually compiling your code.

Disable -Wreturn-type checking

I am trying to compile Model 5.0 under OS X 10.8.3
I am getting a lot of warnings and errors while compiling. Several of those error are something like
xwin.c:31523:2: error: non-void function 'scrfrg' should return a value
[-Wreturn-type]
return;
What flag in C/C++ checks that? I want to disable it and try to finish the compilation.
I'm not sure if this is the best forum to ask this, sorry for the inconvenience.
As per the link you posted, seems you're using gcc. You can disable a lot of error/warning checks with a -Wno-xxxx flag, in your case -Wreturn-type is causing an error so you can disable it with:
-Wno-return-type
Frankly, it's better to just fix the errors/warnings when you can, and that one seems easy to fix.

ARM assembler: bad immediate value for offset

I am using GCC crosscompiler to compile to an ARM platform. I have a problem where, using opitmization -O3 gives me a "bad immediate value for offset (4104)" on a temp file ccm4baaa.s. Can't find this file either.
How do I debug this, or find the source of the error? I know that it's located somewhere in hyper.c, but it's impossible to find it because there is no errors showing in hyper.c. Only the cryptic error message above.
Best Regards
Mr Gigu
There have been similar known bugs in previous releases of GCC. It might just be a matter of updating your version of the GCC toolchain. Which one are you using currently?
In order to debug the problem and find the offending source, in these cases it helps to add the gcc option -save-temps to the compilation. The effect is that the compiler keeps the intermediate assembly files (and the pre-processor output) for you to examine.

Resources