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 }