msvcrt.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. /////////////////////////////////////////////////////////////////////////////
  2. // Name: wx/msw/msvcrt.h
  3. // Purpose: macros to use some non-standard features of MS Visual C++
  4. // C run-time library
  5. // Author: Vadim Zeitlin
  6. // Modified by:
  7. // Created: 31.01.1999
  8. // Copyright: (c) Vadim Zeitlin
  9. // Licence: wxWindows licence
  10. /////////////////////////////////////////////////////////////////////////////
  11. // the goal of this file is to define wxCrtSetDbgFlag() macro which may be
  12. // used like this:
  13. // wxCrtSetDbgFlag(_CRTDBG_LEAK_CHECK_DF);
  14. // to turn on memory leak checks for programs compiled with Microsoft Visual
  15. // C++ (5.0+). The macro will not be defined under other compilers or if it
  16. // can't be used with MSVC for whatever reason.
  17. #ifndef _MSW_MSVCRT_H_
  18. #define _MSW_MSVCRT_H_
  19. // use debug CRT functions for memory leak detections in VC++ 5.0+ in debug
  20. // builds
  21. #undef wxUSE_VC_CRTDBG
  22. #if defined(_DEBUG) && defined(__VISUALC__) && (__VISUALC__ >= 1000) \
  23. && !defined(UNDER_CE)
  24. // it doesn't combine well with wxWin own memory debugging methods
  25. #if !wxUSE_GLOBAL_MEMORY_OPERATORS && !wxUSE_MEMORY_TRACING && !defined(__NO_VC_CRTDBG__)
  26. #define wxUSE_VC_CRTDBG
  27. #endif
  28. #endif
  29. #ifdef wxUSE_VC_CRTDBG
  30. // Need to undef new if including crtdbg.h which may redefine new itself
  31. #ifdef new
  32. #undef new
  33. #endif
  34. #include <stdlib.h>
  35. // Defining _CRTBLD should never be necessary at all, but keep it for now
  36. // as there is no time to retest all the compilers before 3.0 release.
  37. // Definitely do not use it with MSVS 2013 as defining it results in errors
  38. // if the standard <assert.h> is included afterwards.
  39. #if !defined(_CRTBLD) && !wxCHECK_VISUALC_VERSION(12)
  40. // Needed when building with pure MS SDK
  41. #define _CRTBLD
  42. #endif
  43. #include <crtdbg.h>
  44. #undef WXDEBUG_NEW
  45. #define WXDEBUG_NEW new(_NORMAL_BLOCK, __FILE__, __LINE__)
  46. // this define works around a bug with inline declarations of new, see
  47. //
  48. // http://support.microsoft.com/kb/q140858/
  49. //
  50. // for the details
  51. #define new WXDEBUG_NEW
  52. #define wxCrtSetDbgFlag(flag) \
  53. _CrtSetDbgFlag(_CrtSetDbgFlag(_CRTDBG_REPORT_FLAG) | (flag))
  54. #else // !using VC CRT
  55. #define wxCrtSetDbgFlag(flag)
  56. #endif // wxUSE_VC_CRTDBG
  57. #endif // _MSW_MSVCRT_H_