Jeegar Patel
Jeegar Patel

Reputation: 27200

How to disable warnings when compiling C code?

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.

Upvotes: 10

Views: 73885

Answers (4)

arye
arye

Reputation: 490

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

Upvotes: 3

Kracekumar
Kracekumar

Reputation: 20419

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"

Upvotes: 6

DreiBaer
DreiBaer

Reputation: 71

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

Upvotes: 2

frx08
frx08

Reputation: 4432

try to add -w option when compiling

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

Upvotes: 26

Related Questions