__attribute__ ((unused))

2019独角兽企业重金招聘Python工程师标准>>> hot3.png

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

Problem: I received the following warning:

warning: unused variable ''
warning: unused function ''
Solution: If variable or function 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

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