__attribute__ ((unused))

今天编译 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.

你可能感兴趣的:(__attribute__ ((unused)))