Article ID: 111753
Article Last Modified on 10/2/2003
/* Compile options needed: none
*/
#include <windows.h>
#include <stdio.h>
#include <process.h>
// Prototype for the function called by the assert macro.
void ShowAssertion(void * expr, void * filename, unsigned lineno);
// The following should all be on one line. It wraps around because
// of its length.
#define assert(exp) (void)( (exp) || (ShowAssertion(#exp, __FILE__,
__LINE__), 0) )
static char AssertString[] = "Expression %s, File %s, Line %d\n";
void ShowAssertion(void * expr, void * filename, unsigned lineno)
{
char buffer[256];
sprintf( buffer, AssertString, expr, filename, lineno );
MessageBox( NULL, buffer, "ASSERTION FAILED",
MB_OK | MB_ICONHAND | MB_TASKMODAL );
abort();
}
Additional query words: 2.00 debug runtime run time
Keywords: kbcrt kbdocfix kbdocerr KB111753