assert.h

#ifndef ASSERT_H // {
#define ASSERT_H
extern BOOL Debugger();
extern BOOL AssertProc(const char *pszFile, long lwLine, const char *pszMsg);
extern BOOL IsValidReadString(const WCHAR * psz);
extern BOOL IsValidReadStringN(const WCHAR * psz);
extern BOOL IsGoodReadPtr(void * pv, ULONG cb);
extern BOOL IsGoodWritePtr(void * pv, ULONG cb);

#if DEBUG // {
#define AssertMsg(exp, msg) ((exp) || !AssertProc(__FILE__, __LINE__, (msg)) || Debugger())
#else // } DEBUG {
#define AssertMsg(exp, msg)
#endif // DEBUG }

#define Bug(msg) AssertMsg(FALSE, msg)
#define Assert(exp) AssertMsg(exp, #exp)
#define AssertReadStringN(exp) AssertMsg(IsValidReadStringN((exp)), "bad string")
#define AssertReadString(exp) AssertMsg(IsValidReadString((exp)), "bad string")
#define AssertOutPtr(exp) AssertMsg(IsGoodWritePtr((exp), sizeof(void*)), "bad out pointer")
#define AssertReadPtr(exp) AssertMsg(IsGoodReadPtr((exp), sizeof(void*)), "bad pointer")

#endif // ASSERT_H }