要求: 1. 只对指定的函数生效 2. 最好的编译器无关的(我用的是g++,如果不能实现编译器无关的,能让g++心满意足也足够了) 3. 不带来额外的运行时消耗 4. 给人带来的惊讶越小越好。(比如 signal = 0这样的做法就不推荐了)
signal = 0
求各种可行的有趣的quick but not dirty的解决方案。
走同样的路,发现不同的人生
If possible, please use normal methods to eliminate warnings. If it is really unnecessary, just remove it
Method 1:
void foo(int a) { (void)a; // ... }
Method 2:
#ifdef __GNUC__ # define UNUSED(x) UNUSED_ ## x __attribute__((__unused__)) #else # define UNUSED(x) UNUSED_ ## x #endif void foo(int UNUSED(a)) { // ... }
Reference: http://stackoverflow.com/a/12891181
void f(int) { // ... }
If possible, please use normal methods to eliminate warnings. If it is really unnecessary, just remove it
Method 1:
Method 2:
Reference: http://stackoverflow.com/a/12891181