如何在编译C代码时禁用警告?

时间:2022-06-02 00:25:32

I am working on 32-bit Fedora 14 system. I'm compiling my source code using gcc.

我正在研究32位Fedora 14系统。我正在使用gcc编译我的源代码。

Does anybody know how to disable warnings while compiling c code?

有人知道如何在编译c代码时禁用警告吗?

3 个解决方案

#1


15  

try to add -w option when compiling

尝试在编译时添加-w选项

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

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

#2


4  

Every body tells use -Wall switch with gcc, but you want to disable it. It is not advised, Use debugger to find it.

每个人都告诉使用-Wall开关与gcc,但你想禁用它。不建议使用调试器来查找它。

Linus Torvalds:

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"

“但它显然是唯一正确的方式。其他人以其他方式做到的事实只意味着他们错了”

#3


1  

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):

但是,如果您确定没有错误或者您已确定问题被您的代码捕获,请将其放在文件中的某处(其中警告的编号为177):

#pragma diag_suppress 177 // supress #177-D function  was declared but never referenced

#1


15  

try to add -w option when compiling

尝试在编译时添加-w选项

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

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

#2


4  

Every body tells use -Wall switch with gcc, but you want to disable it. It is not advised, Use debugger to find it.

每个人都告诉使用-Wall开关与gcc,但你想禁用它。不建议使用调试器来查找它。

Linus Torvalds:

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"

“但它显然是唯一正确的方式。其他人以其他方式做到的事实只意味着他们错了”

#3


1  

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):

但是,如果您确定没有错误或者您已确定问题被您的代码捕获,请将其放在文件中的某处(其中警告的编号为177):

#pragma diag_suppress 177 // supress #177-D function  was declared but never referenced