Line data Source code
1 : /***************************************************************************** 2 : * myassert.c 3 : * 4 : * DESCRIPTION 5 : * This file contains the code to handle assert statements. There is no 6 : * actual code unless DEBUG is defined. 7 : * 8 : * HISTORY 9 : * 12/2003 Arthur Taylor (MDL / RSIS): Created. 10 : * 11 : * NOTES 12 : ***************************************************************************** 13 : */ 14 : #include <stdio.h> 15 : #include <stdlib.h> 16 : #include "myassert.h" 17 : 18 : /***************************************************************************** 19 : * myAssert() -- Arthur Taylor / MDL 20 : * 21 : * PURPOSE 22 : * This is an Assert routine from "Writing Solid Code" by Steve Maguire. 23 : * 24 : * Advantages of this over "assert" is that assert stores the expression 25 : * string for printing. Where does assert store it? Probably in global data, 26 : * but that means assert is gobbling up space that the program may need for 27 : * no real advantage. If you trigger assert, you're going to look in the file 28 : * and see the code. 29 : * 30 : * ARGUMENTS 31 : * file = Filename that assert was in. (Input) 32 : * lineNum = Line number in file of the assert. (Input) 33 : * 34 : * RETURNS: void 35 : * 36 : * 8/2003 Arthur Taylor (MDL/RSIS): Created. 37 : * 38 : * NOTES 39 : ***************************************************************************** 40 : */ 41 : #ifdef DEBUG 42 0 : void _myAssert (const char *file, int lineNum) 43 : { 44 0 : fflush (NULL); 45 0 : fprintf (stderr, "\nAssertion failed: %s, line %d\n", file, lineNum); 46 0 : fflush (stderr); 47 0 : abort (); 48 : /* exit (EXIT_FAILURE);*/ 49 : } 50 : #endif