]>
Commit | Line | Data |
---|---|---|
fea681da MK |
1 | .\" Copyright (C) 2002 Andries Brouwer <aeb@cwi.nl> |
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. | |
c13182ef | 11 | .\" |
fea681da MK |
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. | |
c13182ef | 19 | .\" |
fea681da MK |
20 | .\" Formatted or processed versions of this manual, if unaccompanied by |
21 | .\" the source, must acknowledge the copyright and authors of this work. | |
22 | .\" | |
23 | .\" This replaces an earlier man page written by Walter Harms | |
24 | .\" <walter.harms@informatik.uni-oldenburg.de>. | |
25 | .\" | |
26 | .TH ASSERT_PERROR 3 2002-08-25 "GNU" "Linux Programmer's Manual" | |
27 | .SH NAME | |
28 | assert_perror \- test errnum and abort | |
29 | .SH SYNOPSIS | |
30 | .nf | |
b80f966b | 31 | .BR "#define _GNU_SOURCE" " /* See feature_test_macros(7) */" |
fea681da MK |
32 | .B #include <assert.h> |
33 | .sp | |
34 | .BI "void assert_perror(int " errnum ); | |
35 | .fi | |
36 | .SH DESCRIPTION | |
37 | If the macro | |
38 | .B NDEBUG | |
39 | was defined at the moment | |
bd12ab88 | 40 | .I <assert.h> |
fea681da | 41 | was last included, the macro |
63aa9df0 | 42 | .BR assert_perror () |
fea681da MK |
43 | generates no code, and hence does nothing at all. |
44 | Otherwise, the macro | |
63aa9df0 | 45 | .BR assert_perror () |
7bbdabc4 | 46 | prints an error message to standard error and terminates the program |
fea681da | 47 | by calling |
fb186734 | 48 | .BR abort (3) |
fea681da MK |
49 | if |
50 | .I errnum | |
c7094399 | 51 | is nonzero. |
c13182ef | 52 | The message contains the filename, function name and |
fea681da MK |
53 | line number of the macro call, and the output of |
54 | .IR strerror(errnum) . | |
55 | .SH "RETURN VALUE" | |
56 | No value is returned. | |
57 | .SH "CONFORMING TO" | |
58 | This is a GNU extension. | |
59 | .SH BUGS | |
60 | The purpose of the assert macros is to help the programmer find bugs in | |
61 | his program, things that cannot happen unless there was a coding mistake. | |
62 | However, with system or library calls the situation is rather different, | |
63 | and error returns can happen, and will happen, and should be tested for. | |
2f0af33b MK |
64 | Not by an assert, where the test goes away when |
65 | .B NDEBUG | |
66 | is defined, | |
c13182ef MK |
67 | but by proper error handling code. |
68 | Never use this macro. | |
fea681da MK |
69 | .SH "SEE ALSO" |
70 | .BR abort (3), | |
71 | .BR assert (3), | |
72 | .BR exit (3), | |
0a90178c MK |
73 | .BR strerror (3), |
74 | .BR feature_test_macros (7) |