Warnings.h 5.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. //-------------------------------------------------------------------------------------------------------
  2. // Copyright (C) Microsoft. All rights reserved.
  3. // Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
  4. //-------------------------------------------------------------------------------------------------------
  5. #pragma once
  6. //=============================
  7. // Enabled Warnings
  8. //=============================
  9. #pragma warning(default:4242) // conversion possible loss of data
  10. //=============================
  11. // Disabled Warnings
  12. //=============================
  13. // Warnings that we don't care about
  14. #pragma warning(disable: 4100) // unreferenced formal parameter
  15. #pragma warning(disable: 4127) // constant expression for Trace/Assert
  16. #pragma warning(disable: 4200) // nonstandard extension used: zero-sized array in struct/union
  17. #pragma warning(disable: 4201) // nameless unions are part of C++
  18. #pragma warning(disable: 4512) // private operator= are good to have
  19. #pragma warning(disable: 4481) // allow use of abstract and override keywords
  20. #pragma warning(disable: 4324) // structure was padded due to alignment specifier
  21. // warnings caused by normal optimizations
  22. #if DBG
  23. #else // DBG
  24. #pragma warning(disable: 4702) // unreachable code caused by optimizations
  25. #pragma warning(disable: 4189) // initialized but unused variable
  26. #pragma warning(disable: 4390) // empty controlled statement
  27. #endif // DBG
  28. // PREFAST warnings
  29. #ifdef _PREFAST_
  30. // Warnings that we don't care about
  31. #pragma warning(disable:6322) // Empty _except block
  32. #pragma warning(disable:6255) // _alloca indicates failure by raising a stack overflow exception. Consider using _malloca instead.
  33. #pragma warning(disable:28112) // A variable (processNativeCodeSize) which is accessed via an Interlocked function must always be accessed via an Interlocked function. See line 1024: It is not always safe to access a variable which is accessed via the Interlocked* family of functions in any other way.
  34. #pragma warning(disable:28159) // Consider using 'GetTickCount64' instead of 'GetTickCount'. Reason: GetTickCount overflows roughly every 49 days. Code that does not take that into account can loop indefinitely. GetTickCount64 operates on 64 bit values and does not have that problem
  35. #pragma warning(disable:6011) // potentially dereferencing null pointer
  36. #pragma warning(disable:6235) // Logical OR with non-zero constant on the left: 1 || <expr>
  37. #pragma warning(disable:6236) // Logical-OR with non-zero constant, e.g., <expr> || 1. We end up with a lot of these in release builds because certain macros (notably CONFIG_FLAG) expand to compile-time constants in release builds and not in debug builds.
  38. #pragma warning(disable:6327) // False constant expr on left side of AND, so right side never evaluated for effects -- e.g., 0 && <expr>
  39. #pragma warning(disable:6239) // NONZEROLOGICALAND: 1 && <expr> ?
  40. #pragma warning(disable:6240) // LOGICALANDNONZERO: <expr> && 1 ?
  41. #pragma warning(disable:6271) // extra argument provided beyond format string - typically due to macro issues
  42. #pragma warning(disable:6323) // use of arithmetic operator on boolean types
  43. #pragma warning(disable:6340) // sign mismatch on printf format string
  44. #pragma warning(disable:6387) // argument to system library function could be null, which is technically UB but generally just an AV (or harmless)
  45. #pragma warning(disable:25037) // True constant expr in AND, e.g., <expr> && 1.
  46. #pragma warning(disable:25038) // False constant expr in AND, e.g., <expr> && 0.
  47. #pragma warning(disable:25039) // True Constant Expr in OR. Seems to be a duplicate of 6236.
  48. #pragma warning(disable:25040) // False Constant Expr in OR, e.g., <expr> || 0.
  49. #pragma warning(disable:25041) // 'if' condition is always true
  50. #pragma warning(disable:25042) // 'if' condition is always false
  51. #pragma warning(disable:26434) // function definition hides a non-virtual function
  52. #pragma warning(disable:26437) // avoid slicing - this is more of a guideline than a rule, and we don't do it often regardless
  53. #pragma warning(disable:26439) // noexcept specifier implied
  54. #pragma warning(disable:26451) // doing math on smaller types than possible
  55. #pragma warning(disable:26454) // arithmetic overflow at compile time (due to us doing "0 - 1" intentionally)
  56. #pragma warning(disable:26495) // member not initialized (generally due to our heavy use of out-of-thread-zeroing allocators)
  57. #ifndef NTBUILD
  58. // Would be nice to clean these up.
  59. #pragma warning(disable:6054) // String 'dumpName' might not be zero-terminated.
  60. #pragma warning(disable:6244) // Local declaration of 'Completed' hides previous declaration at line '76'
  61. #pragma warning(disable:6246) // Local declaration of 'i' hides declaration of the same name in outer scope.
  62. #pragma warning(disable:6326) // Potential comparison of a constant with another constant.
  63. #endif
  64. #endif // _PREFAST_