欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

__attribute__ ((unused))

程序员文章站 2022-07-14 13:17:22
...

今天编译 tcpdump 看到这个选项。。谷歌了下,原来是去除 编译器对未引用的函数的警告的,

Problem: I received the following warning:

warning: unused variable '<variable_name>'
warning: unused function '<function_name>'
Solution: If variable <variable_name> or function <function_name> is not used, it can be removed. If it is only used sometimes, you can use __attribute__((unused)). This attribute suppresses these warnings. For example:
int  __attribute__ ((unused)) myfunction(int parm1, long parm2) { … }
long __attribute__ ((unused)) myvariable;

If there are a large number of unused variables or functions, which can happen with ported code, you can add the -Wno-unused compiler option to your makefile. This option suppresses all unused warnings.

转载于:https://my.oschina.net/sincoder/blog/68031