File: assert.h

package info (click to toggle)
zoo 2.10-9
  • links: PTS
  • area: non-free
  • in suites: woody
  • size: 780 kB
  • ctags: 1,288
  • sloc: ansic: 9,041; asm: 793; makefile: 211
file content (48 lines) | stat: -rw-r--r-- 995 bytes parent folder | download | duplicates (9)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
/* @(#) assert.h 2.1 87/12/25 12:21:32 */

/*
The contents of this file are hereby released to the public domain.

                           -- Rahul Dhesi 1991/07/04

Defines a macro assert() that causes an assertion error if the assertion
fails.

Conditional compilation:

   If NDEBUG is defined then
      assert() is defined as null so all assertions vanish
   else
		if __FILE__ and __LINE__ are defined then
         assertions print message including filename and line number
      else
         assertions print a message but not the filename and line number
      endif
   endif
*/

#ifdef NDEBUG
# define assert(E)
#else

#undef LINE_FILE

#ifdef __LINE__
# ifdef __FILE__
#  define LINE_FILE
# endif
#endif

#ifdef LINE_FILE
# undef LINE_FILE
# define assert(E) \
   { if (!(E)) \
      prterror ('w',"Assertion error in %s:%d.\n", __FILE__, __LINE__); \
   }
#else
# define assert(E) \
   { if (!(E)) \
      prterror ('w', "Assertion error.\n"); \
   }
#endif
#endif /* NDEBUG */