Changes between Version 20 and Version 21 of Guidelines/MaintenanceGuidelines


Ignore:
Timestamp:
Nov 8, 2009, 6:01:40 PM (13 years ago)
Author:
Paul A. Bristow
Comment:

Reordered table and added more examples.

Legend:

Unmodified
Added
Removed
Modified
  • Guidelines/MaintenanceGuidelines

    v20 v21  
    575575To a jamfile add  <toolset>msvc:<cxxflags>/Za # disable MS extensions.[[BR]]
    576576
    577 If it proves impossible to compile with the \Za option (it is reported to cause trouble with the compiler sometimes), just document this, including in the build jamfile.
     577If it proves impossible to compile with the /Za option (it is reported to cause trouble with the MS compiler, sometimes), just document this, including in the build jamfile.
    578578
    579579(You might also consider using Microsoft /Wall if available.  You may find
     
    604604      <toolset>msvc:<warnings>all # == /W4
    605605      <toolset>msvc:<asynch-exceptions>on # Needed for Boost.Test
    606       <toolset>msvc:<cxxflags>/Za # disable MS extensions.
     606      <toolset>msvc:<cxxflags>/Za # Disable MS extensions.
     607      # <toolset>msvc:<cxxflags>/Zc # Enable MS extensions if these are definitely required.
     608      #  The define of macros below prevent warnings about the checked versions of SCL and CRT libraries.
     609      #  Most Boost code does not need these versions (as they are markedly slower).
    607610      <toolset>msvc:<define>_SCL_SECURE_NO_WARNINGS
    608611      <toolset>msvc:<define>_SCL_SECURE_NO_DEPRECATE
     612      <toolset>msvc:<define>_CRT_SECURE_NO_WARNINGS
    609613      <toolset>msvc:<define>_CRT_SECURE_NO_DEPRECATE
    610       <toolset>msvc:<define>_CRT_SECURE_NO_WARNINGS
     614      #  Alternatively, you can just suppress the warnings (probably not the best way).
    611615      <toolset>msvc:<cxxflags>/wd4996 # 'putenv': The POSIX name for this item is deprecated.
    612616      <toolset>msvc:<cxxflags>/wd4512 # assignment operator could not be generated.
     
    629633to the package as possible so that users can still get warnings from *their code*.
    630634
    631 For MSVC, this involves pushing to save the current warning state, disabling the warning, and later popping to restore.
    632 Adding some or all of the warning message is helpful to tell readers what warning is being ignored.
    633 
     635For MSVC, this involves pushing to save the current warning state, disabling the warning, and later popping to restore (abbreviated as ''push'n'pop'').
    634636{{{
    635637#if defined(_MSC_VER)
     
    646648}}}
    647649
    648 If the warning is only for a specific compiler version, us this approach:
     650Adding some or all of the warning message as a comment is helpful to tell ''readers'' what warning is being ignored, for example:
     651
     652{{{
     653#  pragma warning(disable: 4510) // default constructor could not be generated
     654}}}
     655
     656If the warning is only for a specific compiler version, use this approach:
    649657
    650658{{{
     
    668676=== Specific Warnings and Suggested Actions. ===
    669677
    670 ''These are just few for starters and need more especially for gcc. Suggestions may be wrong!  Also need reordering in a table.''
     678''These are just few for starters, and need more, especially for gcc. Suggestions may be wrong! ''
     679
     680The pragma or other code required to suppress warnings is in the right hand box, ready for copy and paste.
    671681
    672682'''Microsoft'''
     
    676686||Warning||Warning Description||Suggestions||Suppression||
    677687
     688
     689||C4100|| unreferenced formal parameter||Either surround the parameter with C comments, for example: int */ my_variable */)or just delete if the variable name is uninformative. If in other's module(s), or you are too busy/idle, at least suppress warning.||#  pragma warning(disable: 4100) // 'name' : unreferenced formal parameter||
     690
     691||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.|| #  pragma warning(disable: 4127) // conditional expression is constant.||
     692
     693||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||
     694
     695||C4506|| no definition for inline function||If you cannot fix, suppress||#  pragma warning(disable: 4506) // no definition for inline function||
     696
    678697||C4512|| assignment operator could not be generated||Suppress using push'n'pop for the module(s) causing the warning.||//#  pragma warning(disable: 4512) // assignment operator could not be generated.||
    679698
    680 || 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.||
    681 
    682 ||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.|| #  pragma warning(disable: 4127) // conditional expression is constant.||
    683 
    684 ||C4100|| unreferenced formal parameter||Either surround the parameter with C comments, for example: int */ my_variable */)or just delete if the variable name is uninformative.||||
    685 
    686 || 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||
    687 
    688 || c4511||  copy constructor could not be generated||This can almost certainly be suppressed.|| #  pragma warning(disable: 4511) // copy constructor could not be generated||
    689 
    690 || 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||
    691 
    692 || 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||
    693 
    694 || C4189|| local variable is initialized but not referenced||This probably indicates a redundant variable and assignment, so probably remove it.If you sure it is required (or has negligible cost for some documentation benefit), suppress.||||
    695 
    696 ||  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.||
    697 
    698 || C4510||  default constructor could not be generated||Suppress.||#  pragma warning(disable: 4510)||
    699 
    700 || C4800|| int' : forcing value to bool 'true' or 'false'||Suppress.||#  pragma warning(disable: 4800) // int' : forcing value to bool 'true' or 'false'
    701 
    702 || 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.||
    703 
    704 ||  C4324||  structure was padded due to __declspec(align())||Suppress||#pragma warning(disable:4324) // structure was padded due to __declspec(align())||
     699||c4511||  copy constructor could not be generated||This can almost certainly be suppressed.|| #  pragma warning(disable: 4511) // copy constructor could not be generated||
     700
     701||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||
     702
     703||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||
     704
     705||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.||||
     706
     707||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.||
     708
     709||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.||
     710
     711||C4324||  structure was padded due to __declspec(align())||Suppress||#pragma warning(disable:4324) // structure was padded due to __declspec(align())||
     712
     713||C4510||  default constructor could not be generated||Suppress.||#  pragma warning(disable: 4510) // default constructor could not be generated||
     714
     715||C4800|| int' : forcing value to bool 'true' or 'false'||Suppress.||#  pragma warning(disable: 4800) // int' : forcing value to bool 'true' or 'false'
     716
     717||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.||
     718
    705719
    706720'''GCC'''