Changes between Version 26 and Version 27 of Guidelines/MaintenanceGuidelines


Ignore:
Timestamp:
Nov 17, 2009, 12:09:41 PM (13 years ago)
Author:
Paul A. Bristow
Comment:

Comments from Patrick Horgan

Legend:

Unmodified
Added
Removed
Modified
  • Guidelines/MaintenanceGuidelines

    v26 v27  
    572572'''What to do'''
    573573
    574 1  Test compilation with the most pedantic setting for the compiler.
    575 
    576 For Microsoft Visual Studio, this means setting level to 4 (command line /W4).[[BR]]
     5741  Test compilation with the most pedantic setting for the compiler, and non-debug mode.
     575
     576'''For Microsoft Visual Studio''', this means setting level to 4 (command line /W4).[[BR]]
    577577For code that doesn't deliberately use Microsoft language extensions, disable them with Disable MS extensions = Yes, command line option /Za[[BR]]
    578578
     
    606606a helpful guide to the byzantine complexity of warnings).[[BR]]
    607607
    608 For GCC this means -Wall -pendantic 
     608'''For GCC''' this means -Wall -pendantic 
    609609
    610610but you might consider adding specific warnings that are to be suppressed, for example:
     
    628628      <toolset>intel:<cxxflags>-nologo
    629629      <toolset>msvc:<warnings>all # == /W4
     630      -<toolset>msvc:<define>_DEBUG # Undefine DEBUG.
     631      <toolset>msvc:<define>NDEBUG # Define NO debug, or release.
    630632      <toolset>msvc:<asynch-exceptions>on # Needed for Boost.Test
    631633      <toolset>msvc:<cxxflags>/Za # Disable MS extensions.
     
    637639      <toolset>msvc:<define>_CRT_SECURE_NO_WARNINGS
    638640      <toolset>msvc:<define>_CRT_SECURE_NO_DEPRECATE
    639       #  Alternatively, you can just suppress the warnings (probably not the best way).
     641      <toolset>msvc:<define>_CRT_NONSTDC_NO_DEPRECATE # Suppresses other warnings about using standard POSIX and C9X.
     642      #  Alternatively, you can just suppress the warnings (perhaps not the best way).
    640643      <toolset>msvc:<cxxflags>/wd4996 # 'putenv': The POSIX name for this item is deprecated.
    641644      <toolset>msvc:<cxxflags>/wd4512 # assignment operator could not be generated.
     
    717720||C4127|| conditional expression is constant||Very common and many believe unhelpful, but a few find it informative, so do not suppress globally.  Even while(true) can trigger this!  Suppress. while(true) can be rewritten as for(;;) eliminating the warning. || #  pragma warning(disable: 4127) // conditional expression is constant.||
    718721
    719 ||C4180||  qualifier applied to function type has no meaning; ignored||This can always be suppressed - but check that you didn't mean to put the const somewhere else.||#  pragma warning(disable: 4180) // qualifier applied to function type has no meaning; ignored||
    720 
    721 ||C4506|| no definition for inline function||If you cannot fix, suppress||#  pragma warning(disable: 4506) // no definition for inline function||
     722||C4180||  qualifier applied to function type has no meaning; ignored||The meaningless qualifier can always be removed (or left as a comment if it informative) - but check that you didn't mean to put the const somewhere else. can always be suppressed.||#  pragma warning(disable: 4180) // qualifier applied to function type has no meaning; ignored||
     723
     724||C4189||local variable is initialized but not referenced||This probably indicates a redundant variable and assignment, so probably remove it. If you are sure it is required (or has negligible cost for some documentation benefit), suppress.||#  pragma warning(disable: 4189) //local variable is initialized but not referenced||
     725
     726||C4224||nonstandard extension used : formal parameter 'arg' was previously defined as a type.||This will bite users who try to compile with Microsoft extensions disabled. So is most undesirable, but may be a major nuisance to change the names in code.However fixing is the Right Thing, but meanwhile suppressing may be helpful.||#  pragma warning(disable: 4224) // formal parameter 'arg' was previously defined as a type.||
     727
     728||C4244|| Conversion: possible loss of data.||Fix, for example changing type or using static_cast is best, suppress with much caution.||# pragma warning(disable:4244) // Conversion: possible loss of data.||
     729
     730||C4324||structure was padded due to __declspec(align())||Suppress||#pragma warning(disable:4324) // structure was padded due to __declspec(align())||
     731
     732||C4506||no definition for inline function||Provide a definition, or if you cannot/will not, suppress.||#  pragma warning(disable: 4506) // no definition for inline function||
    722733
    723734||C4512|| assignment operator could not be generated||Suppress using push'n'pop for the module(s) causing the warning. Adding the declaration (not the definition) of the appropriate operator=() as a private member does the trick as well.||#  pragma warning(disable: 4512) // assignment operator could not be generated.||
    724735
    725 ||c4511||  copy constructor could not be generated||This can almost certainly be suppressed.|| #  pragma warning(disable: 4511) // copy constructor could not be generated||
    726 
    727 ||C4701|| local variable may be used without having been initialized||Best is to recode to avoid the message, but if you are '''very''' sure the message is misleading, suppress.||#  pragma warning(disable: 4701) // local variable may be used without having been initialized||
    728 
    729 ||C4702||  unreachable code||Be very cautious about suppressing this, but use of macros may make this troublesome, so suppress with care, and always locally.||#pragma warning(disable: 4702) // unreachable code||
    730 
    731 ||C4189|| local variable is initialized but not referenced||This probably indicates a redundant variable and assignment, so probably remove it. If you are sure it is required (or has negligible cost for some documentation benefit), suppress.||||
    732 
    733 ||C4224|| nonstandard extension used : formal parameter 'arg' was previously defined as a type.||This will bite users who try to compile with Microsoft extensions disabled. So is most undesirable, but may be a major nuisance to change the names in code.However fixing is the Right Thing, but meanwhile suppressing may be helpful.||#  pragma warning(disable: 4224) // formal parameter 'arg' was previously defined as a type.||
    734 
    735 ||C4244 ||  // Conversion: possible loss of data.||Fix, for example changing type or using static_cast is best, suppress with much caution.||# pragma warning(disable:4244) // Conversion: possible loss of data.||
    736 
    737 ||C4324||  structure was padded due to __declspec(align())||Suppress||#pragma warning(disable:4324) // structure was padded due to __declspec(align())||
    738 
    739 ||C4510||  default constructor could not be generated||Suppress.||#  pragma warning(disable: 4510) // default constructor could not be generated||
    740 
    741 ||C4535|| calling _set_se_translator() requires /EHa || Common from Boost.Test. Suppress warning in jamfile, add to project : requirements ||  <toolset>msvc:<asynch-exceptions>on # calling _set_se_translator() requires /EHa||
    742 
    743 ||C4800|| int' : forcing value to bool 'true' or 'false'||Suppress. writing (intexpr ? true : false) helps as well||#  pragma warning(disable: 4800) // int' : forcing value to bool 'true' or 'false'
     736||c4511||copy constructor could not be generated||Provide constructor (and assignment operator and destructor).  Or suppress.|| #  pragma warning(disable: 4511) // copy constructor could not be generated||
     737
     738||C4510||default constructor could not be generated||Suppress.||#  pragma warning(disable: 4510) // default constructor could not be generated||
     739
     740||C4535||calling _set_se_translator() requires /EHa ||Common from Boost.Test. In jamfile, add to project : requirements ||  <toolset>msvc:<asynch-exceptions>on # calling _set_se_translator() requires /EHa||
     741
     742||C4625||copy constructor could not be generated because a base class copy constructor is inaccessible||Trying to derive from a non-copyable class? Bug?||Fix.||
     743
     744||C4626||assignmentconstructor could not be generated because a base class copy constructor is inaccessible||Trying to derive from a non-copyable class? Bug?||Fix.||
     745
     746||C4701||local variable may be used without having been initialized||Best is to recode to avoid the message, probably just initialising it. But if you are '''very''' sure the message is misleading, and cost of dummy initialisation too high, suppress.||#  pragma warning(disable: 4701) // local variable may be used without having been initialized||
     747
     748||C4702||unreachable code||Best delete or comment-out.  Be very cautious about suppressing this, but use of macros may make this troublesome, so suppress with care, and always locally.||#pragma warning(disable: 4702) // unreachable code||
     749
     750||C4800|| int' : forcing value to bool 'true' or 'false'||Use a bool valued expression, or static_cast. Writing (intexpr ? true : false) helps as well. Or suppress.||#  pragma warning(disable: 4800) // int' : forcing value to bool 'true' or 'false'
    744751
    745752||C4996||'putenv': The POSIX name for this item is deprecated.||Many other messages about using secure versions.Unless you believe that the 'secure' versions are useful, suppress.||#  pragma warning(disable: 4996) // '' was declared deprecated.||
     
    814821              -Wunused-variable 
    815822              -Wvolatile-register-var
    816              
    817          
    818823
    819824    Note that some warning flags are not implied by -Wall. Some of them warn about constructions that users generally do not consider questionable, but which occasionally you might wish to check for; others warn about constructions that are necessary or hard to avoid in some cases, and there is no simple way to modify the code to suppress the warning. Some of them are enabled by -Wextra but many of them must be enabled individually.
     825
    820826-Wextra
    821827    This enables some extra warning flags that are not enabled by -Wall. (This option used to be called -W. The older name is still supported, but the newer name is more descriptive.)