Q_UNUSED() 方法的使用

Q_UNUSED() 没有实质性的作用,用来避免编译器警告

//比如说
 
int testFunc(int a, int b, int c, int d)
{
int e;
return a+b+c;
}
 
//编译器会有警告 d和e未使用;
 
//于是
int testFunc(int a, int b, int c, int d)
{
int e;
 
Q_UNUSED(d)
Q_UNUSED(e)
return a+b+c;
}
 
//多数时候,这样用总不是太好
 
//比如 e,就不该出现,
 
//对于d,也可以 注释掉
 
int testFunc(int a, int b, int c, int  /* d */)
{
//int e;
return a+b+c;
}
原文地址:https://www.cnblogs.com/sggggr/p/12676315.html