| | 263 | e If a warning only appears as false positive because is it in a #ifdef, for example: |
| | 264 | |
| | 265 | {{{ |
| | 266 | void f(int x) { |
| | 267 | // ..code.. |
| | 268 | #ifdef XYZ |
| | 269 | dostuff(x); |
| | 270 | #endif |
| | 271 | // ..code.. |
| | 272 | |
| | 273 | }}} |
| | 274 | |
| | 275 | then the compiler cannot detect that it is a false positive (FP). |
| | 276 | |
| | 277 | then it is recommended by Gabor Horvath [http://blog.gmane.org/gmane.comp.compilers.clang.devel/day=20150827] |
| | 278 | to add a line like "(void) x;" to suppress the warning. |
| | 279 | |
| | 280 | Other possible workarounds (in case you have several unused variables): |
| | 281 | - You can use pragmas to disable some diagnostics for certain regions of code. |
| | 282 | - You can use compiler flags to disable some diagnostics for certain translation units. |
| | 283 | - You can always factor out platform dependent code to multiple files and have the #ifdef on includes. |