memory debugging using VC++ debug CRT works for DLL wxWin builds as well.
The relevant macros are now in include/wx/msw/msvcrt.h git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@1540 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
49
include/wx/msw/msvcrt.h
Normal file
49
include/wx/msw/msvcrt.h
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Name: wx/msw/msvcrt.h
|
||||||
|
// Purpose: macros to use some non-standard features of MS Visual C++
|
||||||
|
// C run-time library
|
||||||
|
// Author: Vadim Zeitlin
|
||||||
|
// Modified by:
|
||||||
|
// Created: 31.01.1999
|
||||||
|
// RCS-ID: $Id$
|
||||||
|
// Copyright: (c) Vadim Zeitlin
|
||||||
|
// Licence: wxWindows license
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
// the goal of this file is to define wxCrtSetDbgFlag() macro which may be
|
||||||
|
// used like this:
|
||||||
|
// wxCrtSetDbgFlag(_CRTDBG_LEAK_CHECK_DF);
|
||||||
|
// to turn on memory leak checks for programs compiled with Microsoft Visual
|
||||||
|
// C++ (5.0+). The macro will expand to nothing under other compilers.
|
||||||
|
|
||||||
|
#ifndef _MSW_MSVCRT_H_
|
||||||
|
#define _MSW_MSVCRT_H_
|
||||||
|
|
||||||
|
// use debug CRT functions for memory leak detections in VC++ if we're not
|
||||||
|
// using wxWindows own methods
|
||||||
|
#if defined(__WXDEBUG__) && defined(_MSC_VER) && !wxUSE_GLOBAL_MEMORY_OPERATORS && !defined(__NO_VC_CRTDBG__)
|
||||||
|
#define wxUSE_VC_CRTDBG
|
||||||
|
#else
|
||||||
|
#undef wxUSE_VC_CRTDBG
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef wxUSE_VC_CRTDBG
|
||||||
|
// VC++ uses this macro as debug/release mode indicator
|
||||||
|
#ifndef _DEBUG
|
||||||
|
#define _DEBUG
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Need to undef new if including crtdbg.h which redefines new itself
|
||||||
|
#ifdef new
|
||||||
|
#undef new
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <crtdbg.h>
|
||||||
|
|
||||||
|
#define wxCrtSetDbgFlag(flag) \
|
||||||
|
_CrtSetDbgFlag(_CrtSetDbgFlag(_CRTDBG_REPORT_FLAG) | (flag))
|
||||||
|
#else // !using VC CRT
|
||||||
|
#define wxCrtSetDbgFlag(flag)
|
||||||
|
#endif // wxUSE_VC_CRTDBG
|
||||||
|
|
||||||
|
#endif // _MSW_MSVCRT_H_
|
@@ -61,11 +61,9 @@
|
|||||||
// Also, OLE is used not just for drag and drop (it's used by automatn.cpp).
|
// Also, OLE is used not just for drag and drop (it's used by automatn.cpp).
|
||||||
// #if wxUSE_DRAG_AND_DROP
|
// #if wxUSE_DRAG_AND_DROP
|
||||||
#if !defined(__GNUWIN32__) && !defined(__SC__) && !defined(__SALFORDC__)
|
#if !defined(__GNUWIN32__) && !defined(__SC__) && !defined(__SALFORDC__)
|
||||||
#include <ole2.h>
|
#include <ole2.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// #endif
|
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
|
||||||
@@ -73,31 +71,7 @@
|
|||||||
#include <commctrl.h>
|
#include <commctrl.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// use debug CRT functions for memory leak detections in VC++ if we're not
|
#include "wx/msw/msvcrt.h"
|
||||||
// using wxWindows own methods
|
|
||||||
#if defined(__WXDEBUG__) && defined(_MSC_VER) && !wxUSE_GLOBAL_MEMORY_OPERATORS && !defined(__NO_VC_CRTDBG__)
|
|
||||||
#define wxUSE_VC_CRTDBG
|
|
||||||
#else
|
|
||||||
#undef wxUSE_VC_CRTDBG
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef wxUSE_VC_CRTDBG
|
|
||||||
// VC++ uses this macro as debug/release mode indicator
|
|
||||||
#ifndef _DEBUG
|
|
||||||
#define _DEBUG
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Need to undef new if including crtdbg.h */
|
|
||||||
#ifdef new
|
|
||||||
#undef new
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <crtdbg.h>
|
|
||||||
|
|
||||||
#if defined(__WXDEBUG__) && wxUSE_GLOBAL_MEMORY_OPERATORS && wxUSE_DEBUG_NEW_ALWAYS
|
|
||||||
#define new new(__FILE__,__LINE__)
|
|
||||||
#endif
|
|
||||||
#endif // wxUSE_VC_CRTDBG
|
|
||||||
|
|
||||||
extern char *wxBuffer;
|
extern char *wxBuffer;
|
||||||
extern char *wxOsVersion;
|
extern char *wxOsVersion;
|
||||||
@@ -163,13 +137,6 @@ bool wxApp::Initialize()
|
|||||||
|
|
||||||
wxBuffer = new char[1500];
|
wxBuffer = new char[1500];
|
||||||
|
|
||||||
#ifdef wxUSE_VC_CRTDBG
|
|
||||||
// do check for memory leaks on program exit
|
|
||||||
// (another useful flag is _CRTDBG_DELAY_FREE_MEM_DF which doesn't free
|
|
||||||
// deallocated memory which may be used to simulate low-memory condition)
|
|
||||||
_CrtSetDbgFlag(_CrtSetDbgFlag(_CRTDBG_REPORT_FLAG) | _CRTDBG_LEAK_CHECK_DF);
|
|
||||||
#endif // debug build under MS VC++
|
|
||||||
|
|
||||||
wxClassInfo::InitializeClasses();
|
wxClassInfo::InitializeClasses();
|
||||||
|
|
||||||
#if wxUSE_RESOURCES
|
#if wxUSE_RESOURCES
|
||||||
@@ -258,8 +225,7 @@ bool wxApp::Initialize()
|
|||||||
|
|
||||||
wxWinHandleList = new wxList(wxKEY_INTEGER);
|
wxWinHandleList = new wxList(wxKEY_INTEGER);
|
||||||
|
|
||||||
// This is to foil optimizations in Visual C++ that
|
// This is to foil optimizations in Visual C++ that throw out dummy.obj.
|
||||||
// throw out dummy.obj.
|
|
||||||
// PLEASE DO NOT ALTER THIS.
|
// PLEASE DO NOT ALTER THIS.
|
||||||
#if defined(_MSC_VER) && !defined(WXMAKINGDLL)
|
#if defined(_MSC_VER) && !defined(WXMAKINGDLL)
|
||||||
extern char wxDummyChar;
|
extern char wxDummyChar;
|
||||||
@@ -590,6 +556,11 @@ int wxEntry(WXHINSTANCE hInstance,
|
|||||||
int nCmdShow,
|
int nCmdShow,
|
||||||
bool enterLoop)
|
bool enterLoop)
|
||||||
{
|
{
|
||||||
|
// do check for memory leaks on program exit
|
||||||
|
// (another useful flag is _CRTDBG_DELAY_FREE_MEM_DF which doesn't free
|
||||||
|
// deallocated memory which may be used to simulate low-memory condition)
|
||||||
|
wxCrtSetDbgFlag(_CRTDBG_LEAK_CHECK_DF);
|
||||||
|
|
||||||
// take everything into a try-except block in release build
|
// take everything into a try-except block in release build
|
||||||
// FIXME other compilers must support Win32 SEH (structured exception
|
// FIXME other compilers must support Win32 SEH (structured exception
|
||||||
// handling) too, just find the appropriate keyword in their docs!
|
// handling) too, just find the appropriate keyword in their docs!
|
||||||
|
@@ -7,8 +7,6 @@
|
|||||||
* Copyright: (c) 1993, AIAI, University of Edinburgh
|
* Copyright: (c) 1993, AIAI, University of Edinburgh
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* static const char sccsid[] = "@(#)dummy.cc 1.2 5/9/94"; */
|
|
||||||
|
|
||||||
/* A dummy file to include wx.h. If precompiling wx.h, I
|
/* A dummy file to include wx.h. If precompiling wx.h, I
|
||||||
* always start by compiling this and producing the PCH file.
|
* always start by compiling this and producing the PCH file.
|
||||||
* Then subsequent source files use the PCH file.
|
* Then subsequent source files use the PCH file.
|
||||||
@@ -22,8 +20,6 @@
|
|||||||
* This will produce a big PCH file.
|
* This will produce a big PCH file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#if defined(__BORLANDC__)
|
#if defined(__BORLANDC__)
|
||||||
#if !(defined(__WIN32__) || defined(__NT__) || defined(__WIN32__))
|
#if !(defined(__WIN32__) || defined(__NT__) || defined(__WIN32__))
|
||||||
#pragma hdrfile "c:\wx\src\msw\wx.pch"
|
#pragma hdrfile "c:\wx\src\msw\wx.pch"
|
||||||
@@ -33,35 +29,44 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "wx/wxprec.h"
|
#include "wx/wxprec.h"
|
||||||
#include "windows.h"
|
|
||||||
|
|
||||||
#ifdef __BORLANDC__
|
#ifdef __BORLANDC__
|
||||||
#pragma hdrstop
|
#pragma hdrstop
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <windows.h>
|
||||||
|
|
||||||
|
#include "wx/msw/msvcrt.h"
|
||||||
|
|
||||||
// Foils optimizations in Visual C++ (see also app.cpp). Without it,
|
// Foils optimizations in Visual C++ (see also app.cpp). Without it,
|
||||||
// dummy.obj isn't linked and we get a linker error.
|
// dummy.obj isn't linked and we get a linker error.
|
||||||
#if defined(_MSC_VER)
|
#if defined(_MSC_VER)
|
||||||
char wxDummyChar=0;
|
char wxDummyChar = 0;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// if wxWindows is in the DLL link our entry point with the application
|
||||||
#if defined(WXUSINGDLL)
|
#if defined(WXUSINGDLL)
|
||||||
|
|
||||||
// NT defines APIENTRY, 3.x not
|
// NT defines APIENTRY, 3.x not
|
||||||
#if !defined(APIENTRY)
|
#if !defined(APIENTRY)
|
||||||
#define APIENTRY FAR PASCAL
|
#define APIENTRY FAR PASCAL
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
int
|
||||||
#ifdef __WATCOMC__
|
#ifdef __WATCOMC__
|
||||||
int PASCAL
|
PASCAL
|
||||||
#else
|
#else
|
||||||
int APIENTRY
|
APIENTRY
|
||||||
#endif
|
#endif
|
||||||
|
WinMain(HINSTANCE hInstance,
|
||||||
WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR m_lpCmdLine,
|
HINSTANCE hPrevInstance,
|
||||||
|
LPSTR m_lpCmdLine,
|
||||||
int nCmdShow )
|
int nCmdShow )
|
||||||
{
|
{
|
||||||
return wxEntry((WXHINSTANCE) hInstance, (WXHINSTANCE) hPrevInstance, m_lpCmdLine, nCmdShow);
|
wxCrtSetDbgFlag(_CRTDBG_LEAK_CHECK_DF);
|
||||||
|
|
||||||
|
return wxEntry((WXHINSTANCE) hInstance, (WXHINSTANCE) hPrevInstance,
|
||||||
|
m_lpCmdLine, nCmdShow);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user