home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / vc98 / mfc / src / dumpout.cpp < prev    next >
C/C++ Source or Header  |  1998-06-16  |  2KB  |  63 lines

  1. // This is a part of the Microsoft Foundation Classes C++ library.
  2. // Copyright (C) 1992-1998 Microsoft Corporation
  3. // All rights reserved.
  4. //
  5. // This source code is only intended as a supplement to the
  6. // Microsoft Foundation Classes Reference and related
  7. // electronic documentation provided with the library.
  8. // See these sources for detailed information regarding the
  9. // Microsoft Foundation Classes product.
  10.  
  11. #include "stdafx.h"
  12. #include <stdarg.h>
  13.  
  14. #ifdef _DEBUG   // entire file
  15.  
  16. #ifdef AFX_AUX_SEG
  17. #pragma code_seg(AFX_AUX_SEG)
  18. #endif
  19.  
  20. #ifdef _DEBUG
  21. #undef THIS_FILE
  22. static char THIS_FILE[] = __FILE__;
  23. #endif
  24.  
  25. /////////////////////////////////////////////////////////////////////////////
  26. // Helper routines that can be called from debugger
  27.  
  28. void AFXAPI AfxDump(const CObject* pOb)
  29. {
  30.     afxDump << pOb;
  31. }
  32.  
  33. /////////////////////////////////////////////////////////////////////////////
  34. // Diagnostic Trace
  35.  
  36. void AFX_CDECL AfxTrace(LPCTSTR lpszFormat, ...)
  37. {
  38. #ifdef _DEBUG // all AfxTrace output is controlled by afxTraceEnabled
  39.     if (!afxTraceEnabled)
  40.         return;
  41. #endif
  42.  
  43.     va_list args;
  44.     va_start(args, lpszFormat);
  45.  
  46.     int nBuf;
  47.     TCHAR szBuffer[512];
  48.  
  49.     nBuf = _vsntprintf(szBuffer, _countof(szBuffer), lpszFormat, args);
  50.  
  51.     // was there an error? was the expanded string too long?
  52.     ASSERT(nBuf >= 0);
  53.  
  54.     if ((afxTraceFlags & traceMultiApp) && (AfxGetApp() != NULL))
  55.         afxDump << AfxGetApp()->m_pszExeName << ": ";
  56.     afxDump << szBuffer;
  57.  
  58.     va_end(args);
  59. }
  60. #endif //_DEBUG
  61.  
  62. /////////////////////////////////////////////////////////////////////////////
  63.