Changes between Version 29 and Version 30 of Guidelines/WarningsGuidelines


Ignore:
Timestamp:
Aug 27, 2015, 5:06:57 PM (7 years ago)
Author:
Paul A. Bristow
Comment:

Adding note about supressing false positive from unused variables inside #ifdef ...

Legend:

Unmodified
Added
Removed
Modified
  • Guidelines/WarningsGuidelines

    v29 v30  
    261261d  If a warning cannot be eliminated or suppressed, explain why in the code and the documentation.  If appropriate, document in build files, as well.  Consider indicating the highest warning level possible or compiler-specific settings that will provide a warning-free build.
    262262
     263e If a warning only appears as false positive because is it in a #ifdef, for example:
     264
     265{{{
     266void f(int x) {
     267    // ..code..
     268 #ifdef XYZ
     269    dostuff(x);
     270#endif
     271   // ..code..
     272
     273}}}
     274
     275then the compiler cannot detect that it is a false positive (FP).
     276
     277then it is recommended by Gabor Horvath  [http://blog.gmane.org/gmane.comp.compilers.clang.devel/day=20150827]
     278to add a line like "(void) x;" to suppress the warning.
     279
     280Other 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.
    263284
    264285=== Specific Warnings and Suggested Actions. ===
     
    10961117[http://docs.sun.com/app/docs/doc/802-5660/6i9debhqe?a=view some Sun workarounds] to some Sun compiler errors/warnings.
    10971118
    1098