Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
4866 Serge 1
/*
2
FUNCTION
3
<>---macro for debugging diagnostics
4
 
5
INDEX
6
	assert
7
 
8
ANSI_SYNOPSIS
9
	#include 
10
	void assert(int <[expression]>);
11
 
12
DESCRIPTION
13
	Use this macro to embed debuggging diagnostic statements in
14
	your programs.  The argument <[expression]> should be an
15
	expression which evaluates to true (nonzero) when your program
16
	is working as you intended.
17
 
18
	When <[expression]> evaluates to false (zero), <>
19
	calls <>, after first printing a message showing what
20
	failed and where:
21
 
22
. Assertion failed: <[expression]>, file <[filename]>, line <[lineno]>, function: <[func]>
23
 
24
	If the name of the current function is not known (for example,
25
	when using a C89 compiler that does not understand __func__),
26
	the function location is omitted.
27
 
28
	The macro is defined to permit you to turn off all uses of
29
	<> at compile time by defining <> as a
30
	preprocessor variable.   If you do this, the <> macro
31
	expands to
32
 
33
. (void(0))
34
 
35
RETURNS
36
	<> does not return a value.
37
 
38
PORTABILITY
39
	The <> macro is required by ANSI, as is the behavior
40
	when <> is defined.
41
 
42
Supporting OS subroutines required (only if enabled): <>, <>,
43
<>, <>, <>, <>, <>, <>, <>.
44
*/
45
 
46
#include 
47
#include 
48
#include 
49
 
50
#ifndef HAVE_ASSERT_FUNC
51
/* func can be NULL, in which case no function information is given.  */
52
void
53
_DEFUN (__assert_func, (file, line, func, failedexpr),
54
	const char *file _AND
55
	int line _AND
56
	const char *func _AND
57
	const char *failedexpr)
58
{
59
  fiprintf(stderr,
60
	   "assertion \"%s\" failed: file \"%s\", line %d%s%s\n",
61
	   failedexpr, file, line,
62
	   func ? ", function: " : "", func ? func : "");
63
  abort();
64
  /* NOTREACHED */
65
}
66
#endif /* HAVE_ASSERT_FUNC */
67
 
68
void
69
_DEFUN (__assert, (file, line, failedexpr),
70
	const char *file _AND
71
	int line _AND
72
	const char *failedexpr)
73
{
74
   __assert_func (file, line, NULL, failedexpr);
75
  /* NOTREACHED */
76
}