OSDN Git Service

Import translated manuals from JM CVS Repository.
[linuxjm/jm.git] / manual / LDP_man-pages / original / man3 / assert.3
1 .\" Copyright (c) 1993 by Thomas Koenig (ig25@rz.uni-karlsruhe.de)
2 .\"
3 .\" Permission is granted to make and distribute verbatim copies of this
4 .\" manual provided the copyright notice and this permission notice are
5 .\" preserved on all copies.
6 .\"
7 .\" Permission is granted to copy and distribute modified versions of this
8 .\" manual under the conditions for verbatim copying, provided that the
9 .\" entire resulting derived work is distributed under the terms of a
10 .\" permission notice identical to this one.
11 .\"
12 .\" Since the Linux kernel and libraries are constantly changing, this
13 .\" manual page may be incorrect or out-of-date.  The author(s) assume no
14 .\" responsibility for errors or omissions, or for damages resulting from
15 .\" the use of the information contained herein.  The author(s) may not
16 .\" have taken the same level of care in the production of this manual,
17 .\" which is licensed free of charge, as they might when working
18 .\" professionally.
19 .\"
20 .\" Formatted or processed versions of this manual, if unaccompanied by
21 .\" the source, must acknowledge the copyright and authors of this work.
22 .\" License.
23 .\" Modified Sat Jul 24 21:42:42 1993 by Rik Faith <faith@cs.unc.edu>
24 .\" Modified Tue Oct 22 23:44:11 1996 by Eric S. Raymond <esr@thyrsus.com>
25 .TH ASSERT 3  2002-08-25 "GNU" "Linux Programmer's Manual"
26 .SH NAME
27 assert \- abort the program if assertion is false
28 .SH SYNOPSIS
29 .nf
30 .B #include <assert.h>
31 .sp
32 .BI "void assert(scalar " expression );
33 .fi
34 .SH DESCRIPTION
35 If the macro
36 .B NDEBUG
37 was defined at the moment
38 .I <assert.h>
39 was last included, the macro
40 .BR assert ()
41 generates no code, and hence does nothing at all.
42 Otherwise, the macro
43 .BR assert ()
44 prints an error message to standard error and terminates the program
45 by calling
46 .BR abort (3)
47 if
48 .I expression
49 is false (i.e., compares equal to zero).
50 .LP
51 The purpose of this macro is to help the programmer find bugs in
52 his program.
53 The message "assertion failed in file foo.c, function
54 do_bar(), line 1287" is of no help at all to a user.
55 .SH "RETURN VALUE"
56 No value is returned.
57 .SH "CONFORMING TO"
58 POSIX.1-2001, C89, C99.
59 In C89,
60 .I expression
61 is required to be of type
62 .I int
63 and undefined behavior results if it is not, but in C99
64 it may have any scalar type.
65 .\" See Defect Report 107 for more details.
66 .SH BUGS
67 .BR assert ()
68 is implemented as a macro; if the expression tested has side-effects,
69 program behavior will be different depending on whether
70 .B NDEBUG
71 is defined.
72 This may create Heisenbugs which go away when debugging
73 is turned on.
74 .SH "SEE ALSO"
75 .BR abort (3),
76 .BR assert_perror (3),
77 .BR exit (3)