Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to disable warnings when compiling C code?

Tags:

c

gcc

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.

like image 840
Jeegar Patel Avatar asked Jul 30 '11 09:07

Jeegar Patel


People also ask

How do I ignore warnings in C?

The short answer: Use "-w" to ignore warnings.

How do I turn off GCC warnings?

To answer your question about disabling specific warnings in GCC, you can enable specific warnings in GCC with -Wxxxx and disable them with -Wno-xxxx. From the GCC Warning Options: You can request many specific warnings with options beginning -W , for example -Wimplicit to request warnings on implicit declarations.

How do you suppress all warnings in C++?

To disable a set of warnings for a given piece of code, you have to start with a “push” pre-processor instruction, then with a disabling instruction for each of the warning you want to suppress, and finish with a “pop” pre-processor instruction. Now let's dive into the code for each compiler.

Will warnings affect whether your code compiles?

Unlike compilation errors, warnings don't interrupt the compilation process. They are not errors from the viewpoint of a programming language, but they may be software bugs. However, many compilers can be customized so that their warnings don't stop the compilation process.


2 Answers

try to add -w option when compiling

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

like image 121
frx08 Avatar answered Sep 17 '22 13:09

frx08


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"

like image 31
Kracekumar Avatar answered Sep 17 '22 13:09

Kracekumar