Changes between Version 7 and Version 8 of Guidelines/WarningsGuidelines
- Timestamp:
- Jan 7, 2011, 3:42:32 PM (12 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Guidelines/WarningsGuidelines
v7 v8 60 60 61 61 '''For Microsoft Visual Studio''', this means setting level to 4 (command line /W4).[[BR]] 62 For code that doesn't deliberately use Microsoft language extensions, disable them with Disable MS extensions = Yes, command line option /Za[[BR]] 62 63 You might also try compiling with the /Za option to disable MS extensions, but this may not be as useful as one might hope for reasons explained by Stephan T. Lavavej from the Microsoft STL team in an authoritative post at [http://article.gmane.org/gmane.comp.lib.boost.devel/212186/] /Za and Warning Guidelines for VC. 64 65 Briefly, there are several problems. Firstly, the latest compilers, especially VC10, is "pretty conformant" and so code is likely to be portable anyway. Secondly, there is a bug which means that valid code fails to compile, and this is not expected to be fixed for some time. Thirdly, is the possible need to link to other libraries, for example regex, that also '''must''' be built with the /Za option. But there is no way to distinguish libraries built with and without this option by filename, so that they cannot co-exist: this is a recipe for trouble! 66 67 The ultimate test of C++ code portability is still testing on as wide a variety of platforms as possible. 68 69 Having said that, if you only have access to a Microsoft platform, before launching code on the full array of testers, you might consider checking if any indications of non-portability emerge from testing with language extensions disabled. 70 71 To do this, (for code that doesn't deliberately use Microsoft language extensions), use the VS IDE to disable them with Disable MS extensions = Yes, which adds command line option /Za[[BR]] 63 72 64 73 To a jamfile add <toolset>msvc:<cxxflags>/Za # disable MS extensions.[[BR]] 65 74 66 If it proves impossible to compile with the /Za option (it is reported to cause trouble with the MS compiler, sometimes), just document this, includingin the build jamfile.75 If it proves impossible to compile with the /Za option (it causes trouble with some MS compilers, sometimes), just document this, including a comment in the build jamfile. 67 76 68 77 If only one (or a few) modules in a test (or other) build require MS extensions, you can selectively 'switch off' this 'disable' in the 'requirements' in the jamfile, for example: … … 91 100 a helpful guide to the byzantine complexity of warnings).[[BR]] 92 101 93 (If you wish to make '''all''' of your VS projects in ''' all''' VS solutions compile with other options '''by default''', you might consider (carefully) editing (with a text editor, very carefully, after keeping a copy of the original) the file C:\Program Files\Microsoft Visual Studio 9.0\VC\VCWizards\1033\common.js to change from the Microsoft defaults. This does not seem to be officially documented as far as I know. It may save you changing the project properties repeatedly.102 (If you '''really''' wish to make '''all''' of your VS projects in ''' all''' VS solutions compile with other options '''by default''', you might consider (carefully) editing (with a text editor, very carefully, after keeping a copy of the original) the file C:\Program Files\Microsoft Visual Studio 9.0\VC\VCWizards\1033\common.js to change from the Microsoft defaults. This does not seem to be officially documented as far as I know. It may save you changing the project properties repeatedly. 94 103 95 104 {{{ 96 105 function AddCommonConfig(oProj, strProjectName,bAddUnicode,bForEmptyProject) in the sections for debug and/or release 97 106 98 CLTool.DisableLanguageExtensions = true; // add to make the default NO MS extensions .107 CLTool.DisableLanguageExtensions = true; // add to make the default NO MS extensions (but you probably don't want this for Boost code). 99 108 100 109 LinkTool.LinkIncremental = linkIncrementalNo; // add … … 129 138 <toolset>msvc:<define>NDEBUG # Define NO debug, or release. 130 139 <toolset>msvc:<asynch-exceptions>on # Needed for Boost.Test 131 <toolset>msvc:<cxxflags>/Za # Disable MS extensions.140 # <toolset>msvc:<cxxflags>/Za # Disable MS extensions, if required, but see above. 132 141 #-<toolset>msvc:<cxxflags>/Za # (Re-)Enable MS extensions if these are definitely required for specific module. 133 142 # The define of macros below prevent warnings about the checked versions of SCL and CRT libraries.