Changes between Version 4 and Version 5 of Guidelines/WarningsGuidelines
- Timestamp:
- Sep 2, 2010, 10:03:41 AM (12 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Guidelines/WarningsGuidelines
v4 v5 211 211 If you chose to suppress (rather than fix by recoding), 212 212 localise the warnings as far as possible by using push'n'pop pragmas (see above). 213 213 214 ||Warning||Warning Description||Suggestions||Suppression|| 214 215 216 215 ||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. In generic code you might not be able to comment the variable name as it might actually be used to call a static function. In this case simply referencing the variable (varname;) in the function body eliminates the warning.||# pragma warning(disable: 4100) // 'name' : unreferenced formal parameter|| 217 218 216 ||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.|| 219 220 217 ||C4146|| unary minus operator applied to unsigned type, result still unsigned||This indicates a real error. ||Fix. || 221 222 218 ||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|| 223 224 219 ||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|| 225 226 220 ||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. Wrong warning acknowledged by MS as a bug http://tinyurl.com/2blmq3l but won't be fixed. May be a major nuisance to change the names in the code but suppressing is fine.||# pragma warning(disable: 4224) // formal parameter 'arg' was previously defined as a type.|| 227 228 221 ||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.|| 229 230 222 ||C4324||structure was padded due to __declspec(align())||Suppress||#pragma warning(disable:4324) // structure was padded due to __declspec(align())|| 231 232 223 ||C4503||decorated name length exceeded||Suppress. (Note that \boost\config\compiler\visualc.hpp includes this global suppression: #pragma warning(disable:4503)||#pragma warning( disable : 4503 ) // warning: decorated name length exceeded|| 233 234 224 ||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|| 235 236 225 ||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.|| 237 238 226 ||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|| 239 240 227 ||C4510||default constructor could not be generated.||If have reference or const members provide default constructor with initializer list. If intent is to make non-default-constructable, provide private declaration only. Suppress.||# pragma warning(disable: 4510) // default constructor could not be generated|| 241 242 228 ||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|| 243 244 229 ||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.|| 245 246 230 ||C4626||assignmentconstructor could not be generated because a base class copy constructor is inaccessible||Trying to derive from a non-copyable class? Bug?||Fix.|| 247 248 231 ||C4671||the copy constructor is inaccessible||Suppress?||#pragma warning(disable: 4671) // the copy constructor is inaccessible|| 249 250 232 ||C4673||A throw object cannot be handled in the catch block.||Fix ?||#pragma warning(disable: 4673) // Thrown object cannot be handled in catch block.|| 251 252 233 ||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|| 253 254 234 ||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|| 255 256 235 ||C4710||'function' : function not inlined||If variable is volatile, suppress.||#pragma warning(disable: 4510) // function not inlined.|| 257 258 236 ||C4725||inline assembly instruction that may not produce accurate results on some Pentium microprocessors.|| Now obselete. Suppress.||#pragma warning(disable: 4510) // inaccurate results on some Pentium microprocessors? || 259 260 237 ||C4800|| int' : forcing value to bool 'true' or 'false'||Use a bool valued expression. Write out expressions, for example: "value >= 0" or "ptr != 0" (Boost prefers clarity to curtness). Take care if using templates that constants are of the right type, for example you may need "value == static_cast<T>(1)". Or use static_cast<bool>(expression). Or suppress.||# pragma warning(disable: 4800) // int' : forcing value to bool 'true' or 'false' 261 262 238 ||C4996||'putenv': The POSIX name for this item is deprecated (but NOT by POSIX!).||Suppress.||# pragma warning(disable: 4996) // 'putenv' was declared deprecated.|| 263 264 239 ||C4996||' this item is deprecated.||Many similar messages suggest using secure versions. Unless you strongly believe that the 'secure' versions are useful, suppress. [http://www.open-std.org/JTC1/sc22/wg14/www/docs/n1160.pdf WG14 Austin Group concerns] may guide. See also _CRT_SECURE_NO_DEPRECATE and other defines above.||# pragma warning(disable: 4996) // '' was declared deprecated.|| 265 240