home *** CD-ROM | disk | FTP | other *** search
/ Mastering Visual Basic 6 / mastvb6.iso / numega / sc501.exe / data1.cab / Examples / DEBUG.H < prev    next >
Encoding:
C/C++ Source or Header  |  1997-11-25  |  2.3 KB  |  86 lines

  1. /*
  2.  * Debug.h
  3.  * $Header: /bcsample/BUGBNCHX/MAINERR/DEBUG.H 1     5/28/96 1:11p Dave $
  4.  *
  5.  * Description:
  6.  *  Diagnostic support routines
  7.  *
  8.  * Notes:
  9.  *  Much of the implementation was taken from the Win32
  10.  *  sample, MCITEST.
  11.  *
  12.  ***********************************************************************
  13.  *
  14.  * Nu-Mega Technologies, Inc.
  15.  * P.O. Box 7780
  16.  * Nashua, NH 03060
  17.  *
  18.  * (c) Copyright 1994, 1995 Nu-Mega Technologies, Inc.
  19.  * ALL RIGHTS RESERVED.
  20.  *
  21.  ***********************************************************************
  22.  *
  23.  **********************************************************************/
  24.  
  25. #ifndef __DEBUG_H__
  26. #define __DEBUG_H__
  27.  
  28. #ifdef __cplusplus
  29. extern "C" {
  30. #endif
  31.  
  32. #ifdef _DEBUG
  33.  
  34.    extern void dDbgOut    ( LPTSTR lpszFormat, ... );
  35.    extern void dDbgAssert ( LPTSTR szExp , LPTSTR szFile , int nLine );
  36.  
  37.    extern DWORD __dwEval;
  38.  
  39.    #define dprintf( _x_ )    dDbgOut _x_
  40.    #define dprintf1( _x_ )   dDbgOut _x_
  41.    #define dprintf2( _x_ )   dDbgOut _x_
  42.    #define dprintf3( _x_ )   dDbgOut _x_
  43.  
  44.    #define WinAssert(exp) \
  45.       ((exp) ? (void)0 : dDbgAssert(#exp, __FILE__, __LINE__))
  46.  
  47.    #define WinEval(exp) \
  48.       ((__dwEval=(DWORD)(exp)),  \
  49.       __dwEval ? (void)0 : dDbgAssert(#exp, __FILE__, __LINE__), __dwEval)
  50.  
  51.    // Provide MFC-like diagnostic support
  52.    #define ASSERT(exp) WinAssert(exp)
  53.    #define VERIFY(exp) WinEval(exp)
  54.    #define TRACE( _x_ )                  dprintf( (_x_) )
  55.    #define TRACE1( _x_ , p )             dprintf1( (_x_ , p) )
  56.    #define TRACE2( _x_ , p1 , p2 )       dprintf2( (_x_ , p1 , p2) )
  57.    #define TRACE3( _x_ , p1 , p2 , p3 )  dprintf3( (_x_ , p1 , p2 , p3) )
  58.  
  59. #else
  60.  
  61.    #define dprintf( _x_ )
  62.    #define dprintf1( _x_ )
  63.    #define dprintf2( _x_ )
  64.    #define dprintf3( _x_ )
  65.    #define dprintf4( _x_ )
  66.  
  67.    #define WinAssert(exp) 0
  68.    #define WinEval(exp) (exp)
  69.  
  70.    #define ASSERT(exp) WinAssert(exp)
  71.    #define VERIFY(exp) WinEval(exp)
  72.    #define TRACE( _x_ )                  dprintf( (_x_) )
  73.    #define TRACE1( _x_ , p )             dprintf1( (_x_ , p) )
  74.    #define TRACE2( _x_ , p1 , p2 )       dprintf2( (_x_ , p1 , p2) )
  75.    #define TRACE3( _x_ , p1 , p2 , p3 )  dprintf3( (_x_ , p1 , p2 , p3) )
  76.  
  77. #endif
  78.  
  79.  
  80. #ifdef __cplusplus
  81. }
  82. #endif
  83.  
  84.  
  85. #endif // __DEBUG_H__
  86.