Warnings.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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:6235) // Logical OR with non-zero constant on the left: 1 || <expr>
  36. #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.
  37. #pragma warning(disable:6327) // False constant expr on left side of AND, so right side never evaluated for effects -- e.g., 0 && <expr>
  38. #pragma warning(disable:6239) // NONZEROLOGICALAND: 1 && <expr> ?
  39. #pragma warning(disable:6240) // LOGICALANDNONZERO: <expr> && 1 ?
  40. #pragma warning(disable:25037) // True constant expr in AND, e.g., <expr> && 1.
  41. #pragma warning(disable:25038) // False constant expr in AND, e.g., <expr> && 0.
  42. #pragma warning(disable:25039) // True Constant Expr in OR. Seems to be a duplicate of 6236.
  43. #pragma warning(disable:25040) // False Constant Expr in OR, e.g., <expr> || 0.
  44. #pragma warning(disable:25041) // 'if' condition is always true
  45. #pragma warning(disable:25042) // 'if' condition is always false
  46. #ifndef NTBUILD
  47. // Would be nice to clean these up.
  48. #pragma warning(disable:6054) // String 'dumpName' might not be zero-terminated.
  49. #pragma warning(disable:6244) // Local declaration of 'Completed' hides previous declaration at line '76'
  50. #pragma warning(disable:6246) // Local declaration of 'i' hides declaration of the same name in outer scope.
  51. #pragma warning(disable:6326) // Potential comparison of a constant with another constant.
  52. #endif
  53. #endif // _PREFAST_