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

 1 //比如说
 2  
 3 int testFunc(int a, int b, int c, int d)
 4 {
 5   int e;
 6   return a+b+c;
 7 }
 8  
 9 //编译器会有警告 d和e未使用;
10  
11 //于是
12 int testFunc(int a, int b, int c, int d)
13 {
14   int e;
15  
16   Q_UNUSED(d)
17   Q_UNUSED(e)
18   return a+b+c;
19 }
20  
21 //多数时候,这样用总不是太好
22  
23 //比如 e,就不该出现,
24  
25 //对于d,也可以 注释掉
26  
27 int testFunc(int a, int b, int c, int  /* d */)
28 {
29   //int e;
30   return a+b+c;
31 }

 

相关文章:

  • 2022-12-23
  • 2021-12-07
  • 2021-10-17
  • 2021-10-05
  • 2021-08-08
  • 2022-02-01
  • 2022-01-15
猜你喜欢
  • 2022-01-24
  • 2021-11-29
  • 2021-08-06
  • 2022-12-23
  • 2022-12-23
  • 2021-09-30
相关资源
相似解决方案