Category : C++ Source Code
Archive   : VCCRT1.ZIP
Filename : ASSERT.C

 
Output of file : ASSERT.C contained in archive : VCCRT1.ZIP
/***
*assert.c - Display a message and abort
*
* Copyright (c) 1988-1992, Microsoft Corporation. All rights reserved.
*
*Purpose:
*
*******************************************************************************/

#ifdef _WINDOWS
#include
#else
#include
#endif

#include
#include

#ifdef _WINDOWS
#undef NULL
#include
#endif

#undef NDEBUG /* ensures prototype is seen */
#include

#ifdef _WINDOWS
static char _assertstring[] = "Expression %s, File %s, Line %d\n";
#else
static char _assertstring[] = "Assertion failed: %s, file %s, line %d\n";
#endif

/***
*_assert() - Display a message and abort
*
*Purpose:
* The assert macro calls this routine if the assert expression is
* true. By placing the assert code in a subroutine instead of within
* the body of the macro, programs that call assert multiple times will
* save space.
*
#ifdef _WINDOWS
* WINDOWS NOTES: Under Windows, a message box is used to display the
* assertion message. The message is built in _assertbuf[] and must be
* no more than 256 bytes (though no check is made!). _assertbuf is
* statically allocated in the ordinary Windows libs, but allocated off
* of the stack in the DLL support libs.
#endif
*
*Entry:
*
*Exit:
*
*Exceptions:
*
#ifdef _WINDOWS
* The Windows version will behave unpredictably, probably crash, if the
* assertion message is more than 256 bytes long.
#endif
*
*******************************************************************************/

void _assert(expr, filename, lineno)
void *expr;
void *filename;
unsigned lineno;
{
#ifdef _WINDOWS

_WINSTATIC char _assertbuf[256];

#ifdef _WINDLL
wsprintf(_assertbuf, _assertstring,
(char far *) expr, (char far *) filename, lineno);
#else
sprintf(_assertbuf, _assertstring, expr, filename, lineno);
#endif
MessageBox(NULL, _assertbuf, "ASSERTION FAILED", MB_OK | MB_ICONHAND | MB_TASKMODAL);

#else /* !_WINDOWS */

if ( !anybuf(stderr) )
/*
* stderr is unused, hence unbuffered, as yet. set it to
* single character buffering (to avoid a malloc() of a
* stream buffer).
*/
(void) setvbuf(stderr, NULL, _IONBF, 0);

fprintf(stderr, _assertstring, expr, filename, lineno);
fflush(stderr);

#endif /* _WINDOWS */

abort();
}


  3 Responses to “Category : C++ Source Code
Archive   : VCCRT1.ZIP
Filename : ASSERT.C

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/