Changes between Version 15 and Version 16 of Guidelines/MaintenanceGuidelines


Ignore:
Timestamp:
Nov 5, 2009, 4:59:45 PM (13 years ago)
Author:
Paul A. Bristow
Comment:

Sugestion from Robert Stewart

Legend:

Unmodified
Added
Removed
Modified
  • Guidelines/MaintenanceGuidelines

    v15 v16  
    539539
    540540-----------------------------------------------------------------------------------------------
    541 == Warnings from Compilers (and other tools) - Code-Round, Suppress Warnings, or Document. == #warnings
     541== Managing Warnings from Compilers (and other tools) == #warnings
     542
     543=== Avoid warnings, Eliminate warning, Suppress Warnings, or Document. ===
    542544
    543545Boost aims to avoid warnings messages as far as is reasonably practicable,
     
    545547avoiding vendor specific extensions if possible.
    546548
    547 '''Some reasons are:'''
    548 
    549 1  To allow users whose environment enforces these conditions to use Boost code.
     549'''Reasons to eliminate or suppress warnings:'''
     550
     5511  To allow users, whose environment requires no warnings, to use Boost code.
    550552
    5515532  To avoid the nuisance, perhaps overwhelming, of spurious warning messages.
    552554
    553 3  To improve code quality by focussing library writers attention on potential problems.
    554 
    555 4  To improve portability by drawing attention to potentially non-portable code.
     5553  To improve code quality by focusing library writers' attention on potential problems.
     556
     5574  To improve portability by focusing developer attention on potentially non-portable code.
    556558
    5575595  To improve compliance with the C++ Standard.
    558560
    559 6  To make it possible for users to enable high warning levels compiling their own code
    560 without being confused by a barrage of warnings from library code.
     5616  To permit users to set high warning levels when using Boost libraries without being overwhelmed with a barrage of library warnings.
    561562
    5625637  To document that warnings have been considered by the library author or maintainer
     
    575576For GCC this means -Wall -pendantic 
    576577
    577 Using bjam add warnings=all to the invocation line.
     578but you might consider adding specific warnings that are to be suppressed, for example:
     579
     580-pedantic -Wall -Wno-long-long -Wno-unused-value
     581
     582but this is a global setting, so you need to document that these warning must be suppressed by users of this module.  This may be acceptable if they are building a library of entirely Boost modules.
     583
     584Using bjam add warnings=all to the invocation command line.
    578585
    579586Putting options in jam files allows setting to be made for one or more specified compiler(s).
     
    604611}}}
    605612
     613Using warning-as-errors will make it hard to miss warnings.
     614  Microsoft command line option /WX,
     615  gcc option -warning-as-errors
     616
    6066172  Consider each warning and
    607618
    608 a  Rewrite the C++ code to avoid the error.  For example, a static_cast makes it clear that
    609 the warned-about potential loss of accuracy has been considered but is not believed to be possible or significant.
    610 
    611 Or placing /* comment */ around an unused variable name, allows the name still to be useful documentation.
    612 
    613 b  Use the compiler specific mechanism to supress the warning message, but try hard to ensure that this is as local
     619a  Rewrite the code to avoid the warning, if possible. For example, adding a static_cast will indicate that any warning about loss of accuracy has been judged not possible or significant. Remove or comment out parameters to avoid warnings about unused parameters. Placing /* comment */ around an unused variable name, allows the name still to be useful documentation.
     620
     621b  Use the compiler specific mechanism to suppress the warning message, but try hard to ensure that this is as local
    614622to the package as possible so that users can still get warnings from *their code*.
    615623
     
    620628#if defined(_MSC_VER)
    621629#pragma warning(push) // Save warning settings.
    622 #pragma warning(disable : 4996) // disable deprecated localtime/gmtime warning.
     630#pragma warning(disable : 4996) // Disable deprecated localtime/gmtime warning.
    623631#endif
    624632
     
    631639}}}
    632640
    633 
    634 If the warning is only for a specific compiler version
    635 
     641If the warning is only for a specific compiler version, us this approach:
    636642
    637643{{{
     
    648654}}}
    649655
    650 c  Repeat this process with other compilers and use their specific supression methods.
    651 
    652 d  Document the code and the associated documentation, and build tools like bjam to say that it is not possible
    653 to use some pedantic-ness level for this module, and why.
    654 
    655 
    656 
    657 
    658 
    659 
    660 
     656c  Repeat this process with other compilers and use their specific suppression methods.
     657
     658d  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.
     659
     660
     661
     662
     663