DEBUG.H

#ifndef DEBUG_H 
#define DEBUG_H
/*
**-----------------------------------------------------------------------------
** File: Debug.h
** Purpose: Sample Debug code
** Notes:
**
** Copyright (c) 1995 - 1997 by Microsoft, all rights reserved
**-----------------------------------------------------------------------------
*/

/*
**-----------------------------------------------------------------------------
** Include files
**-----------------------------------------------------------------------------
*/

#include "Common.h"



/*
**-----------------------------------------------------------------------------
** Defines
**-----------------------------------------------------------------------------
*/

#ifdef DEBUG
// Note: Define DEBUG_PROMPT_ME if you want MessageBox Error prompting
// This can get annoying quickly...
// #define DEBUG_PROMPT_ME

// Pre and Post debug string info
#define START_STRTEXT ("BOIDS: ")
#define END_STRTEXT ("\r\n")
#endif // DEBUG

// Debug Levels
#define DEBUG_ALWAYS0L
#define DEBUG_CRITICAL1L
#define DEBUG_ERROR2L
#define DEBUG_MINOR3L
#define DEBUG_WARN4L
#define DEBUG_DETAILS5L


// Sample Errors
#define APPERR_GENERICMAKE_DDHRESULT (10001)
#defineAPPERR_INVALIDPARAMSMAKE_DDHRESULT (10002)
#define APPERR_NOTINITIALIZEDMAKE_DDHRESULT (10003)
#define APPERR_OUTOFMEMORYMAKE_DDHRESULT (10004)
#define APPERR_NOTFOUNDMAKE_DDHRESULT (10005)



/*
**-----------------------------------------------------------------------------
** Macros
**-----------------------------------------------------------------------------
*/

#ifdef DEBUG
#define DPF dprintf
#define ASSERT(x) \
if (! (x)) \
{ \
DPF (DEBUG_ALWAYS, TEXT("Assertion violated: %s, File = %s, Line = #%ld\n"), \
TEXT(#x), TEXT(__FILE__), (DWORD)__LINE__ ); \
abort (); \
}

#define REPORTERR(x) \
ReportDDError ((x), TEXT("File = %s, Line = #%ld\n"), \
TEXT(__FILE__), (DWORD)__LINE__ );

#define FATALERR(x) \
ReportDDError ((x), TEXT("File = %s, Line = #%ld\n"), \
TEXT(__FILE__), (DWORD)__LINE__ ); \
OnPause (TRUE); \
DestroyWindow (g_hMainWindow);
#else
#define REPORTERR(x)
#define DPF 1 ? (void)0 : (void)
#define ASSERT(x)
#define FATALERR(x) \
OnPause (TRUE); \
DestroyWindow (g_hMainWindow);
#endif // DEBUG



/*
**-----------------------------------------------------------------------------
** Global Variables
**-----------------------------------------------------------------------------
*/

// Debug Variables
#ifdef DEBUG
extern DWORD g_dwDebugLevel;
#endif

extern BOOL g_fDebug;



/*
**-----------------------------------------------------------------------------
** Function Prototypes
**-----------------------------------------------------------------------------
*/

// Debug Routines
#ifdef DEBUG
void __cdecl dprintf (DWORD dwDebugLevel, LPCTSTR szFormat, ...);
#endif //DEBUG

void _cdecl ReportDDError (HRESULT hResult, LPCTSTR szFormat, ...);

/*
**-----------------------------------------------------------------------------
** End of File
**-----------------------------------------------------------------------------
*/
#endif // End DEBUG_H