sl@0
|
1 |
/*
|
sl@0
|
2 |
* Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
3 |
* All rights reserved.
|
sl@0
|
4 |
* This component and the accompanying materials are made available
|
sl@0
|
5 |
* under the terms of "Eclipse Public License v1.0"
|
sl@0
|
6 |
* which accompanies this distribution, and is available
|
sl@0
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
sl@0
|
8 |
*
|
sl@0
|
9 |
* Initial Contributors:
|
sl@0
|
10 |
* Nokia Corporation - initial contribution.
|
sl@0
|
11 |
*
|
sl@0
|
12 |
* Contributors:
|
sl@0
|
13 |
*
|
sl@0
|
14 |
* Description:
|
sl@0
|
15 |
* FUNCTION
|
sl@0
|
16 |
* <<assert>>---Macro for Debugging Diagnostics
|
sl@0
|
17 |
* INDEX
|
sl@0
|
18 |
* assert
|
sl@0
|
19 |
* ANSI_SYNOPSIS
|
sl@0
|
20 |
* #include <assert.h>
|
sl@0
|
21 |
* void assert(int <[expression]>);
|
sl@0
|
22 |
* TRAD_SYNOPSIS
|
sl@0
|
23 |
* #include <assert.h>
|
sl@0
|
24 |
* assert(<[expression]>)
|
sl@0
|
25 |
* int <[expression]>;
|
sl@0
|
26 |
* Use this macro to embed debuggging diagnostic statements in
|
sl@0
|
27 |
* your programs. The argument <[expression]> should be an
|
sl@0
|
28 |
* expression which evaluates to true (nonzero) when your program
|
sl@0
|
29 |
* is working as you intended.
|
sl@0
|
30 |
* When <[expression]> evaluates to false (zero), <<assert>>
|
sl@0
|
31 |
* calls <<abort>>, after first printing a message showing what
|
sl@0
|
32 |
* failed and where:
|
sl@0
|
33 |
* . Assertion failed: <[expression]>, file <[filename]>, line <[lineno]>
|
sl@0
|
34 |
* The macro is defined to permit you to turn off all uses of
|
sl@0
|
35 |
* <<assert>> at compile time by defining <<NDEBUG>> as a
|
sl@0
|
36 |
* preprocessor variable. If you do this, the <<assert>> macro
|
sl@0
|
37 |
* expands to
|
sl@0
|
38 |
* . (void(0))
|
sl@0
|
39 |
* RETURNS
|
sl@0
|
40 |
* <<assert>> does not return a value.
|
sl@0
|
41 |
* PORTABILITY
|
sl@0
|
42 |
* The <<assert>> macro is required by ANSI, as is the behavior
|
sl@0
|
43 |
* when <<NDEBUG>> is defined.
|
sl@0
|
44 |
* Supporting OS subroutines required (only if enabled): <<close>>, <<fstat>>,
|
sl@0
|
45 |
* <<getpid>>, <<isatty>>, <<kill>>, <<lseek>>, <<read>>, <<sbrk>>, <<write>>.
|
sl@0
|
46 |
*
|
sl@0
|
47 |
*
|
sl@0
|
48 |
*/
|
sl@0
|
49 |
|
sl@0
|
50 |
|
sl@0
|
51 |
|
sl@0
|
52 |
#include <assert.h>
|
sl@0
|
53 |
#include <stdlib.h>
|
sl@0
|
54 |
#include <stdio.h>
|
sl@0
|
55 |
|
sl@0
|
56 |
EXPORT_C void __assert (const char *file, int line, const char *failedexpr)
|
sl@0
|
57 |
{
|
sl@0
|
58 |
(void)fprintf(stderr,
|
sl@0
|
59 |
"assertion \"%s\" failed: file \"%s\", line %d\n",
|
sl@0
|
60 |
failedexpr, file, line);
|
sl@0
|
61 |
abort();
|
sl@0
|
62 |
/* NOTREACHED */
|
sl@0
|
63 |
}
|