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