]>
Commit | Line | Data |
---|---|---|
fea681da MK |
1 | .\" Copyright (C) 2002 Andries Brouwer <aeb@cwi.nl> |
2 | .\" | |
93015253 | 3 | .\" %%%LICENSE_START(VERBATIM) |
fea681da MK |
4 | .\" Permission is granted to make and distribute verbatim copies of this |
5 | .\" manual provided the copyright notice and this permission notice are | |
6 | .\" preserved on all copies. | |
7 | .\" | |
8 | .\" Permission is granted to copy and distribute modified versions of this | |
9 | .\" manual under the conditions for verbatim copying, provided that the | |
10 | .\" entire resulting derived work is distributed under the terms of a | |
11 | .\" permission notice identical to this one. | |
c13182ef | 12 | .\" |
fea681da MK |
13 | .\" Since the Linux kernel and libraries are constantly changing, this |
14 | .\" manual page may be incorrect or out-of-date. The author(s) assume no | |
15 | .\" responsibility for errors or omissions, or for damages resulting from | |
16 | .\" the use of the information contained herein. The author(s) may not | |
17 | .\" have taken the same level of care in the production of this manual, | |
18 | .\" which is licensed free of charge, as they might when working | |
19 | .\" professionally. | |
c13182ef | 20 | .\" |
fea681da MK |
21 | .\" Formatted or processed versions of this manual, if unaccompanied by |
22 | .\" the source, must acknowledge the copyright and authors of this work. | |
4b72fb64 | 23 | .\" %%%LICENSE_END |
fea681da MK |
24 | .\" |
25 | .\" This replaces an earlier man page written by Walter Harms | |
26 | .\" <walter.harms@informatik.uni-oldenburg.de>. | |
27 | .\" | |
4b8c67d9 | 28 | .TH ASSERT_PERROR 3 2017-09-15 "GNU" "Linux Programmer's Manual" |
fea681da MK |
29 | .SH NAME |
30 | assert_perror \- test errnum and abort | |
31 | .SH SYNOPSIS | |
32 | .nf | |
b80f966b | 33 | .BR "#define _GNU_SOURCE" " /* See feature_test_macros(7) */" |
fea681da | 34 | .B #include <assert.h> |
68e4db0a | 35 | .PP |
fea681da MK |
36 | .BI "void assert_perror(int " errnum ); |
37 | .fi | |
38 | .SH DESCRIPTION | |
39 | If the macro | |
40 | .B NDEBUG | |
41 | was defined at the moment | |
bd12ab88 | 42 | .I <assert.h> |
fea681da | 43 | was last included, the macro |
63aa9df0 | 44 | .BR assert_perror () |
fea681da MK |
45 | generates no code, and hence does nothing at all. |
46 | Otherwise, the macro | |
63aa9df0 | 47 | .BR assert_perror () |
7bbdabc4 | 48 | prints an error message to standard error and terminates the program |
fea681da | 49 | by calling |
fb186734 | 50 | .BR abort (3) |
fea681da MK |
51 | if |
52 | .I errnum | |
c7094399 | 53 | is nonzero. |
c13182ef | 54 | The message contains the filename, function name and |
fea681da MK |
55 | line number of the macro call, and the output of |
56 | .IR strerror(errnum) . | |
47297adb | 57 | .SH RETURN VALUE |
fea681da | 58 | No value is returned. |
24d428e4 MS |
59 | .SH ATTRIBUTES |
60 | For an explanation of the terms used in this section, see | |
61 | .BR attributes (7). | |
62 | .TS | |
63 | allbox; | |
64 | lb lb lb | |
65 | l l l. | |
66 | Interface Attribute Value | |
67 | T{ | |
68 | .BR assert_perror () | |
69 | T} Thread safety MT-Safe | |
70 | .TE | |
847e0d88 | 71 | .sp 1 |
47297adb | 72 | .SH CONFORMING TO |
fea681da MK |
73 | This is a GNU extension. |
74 | .SH BUGS | |
886ea57d MK |
75 | The purpose of the assert macros is to help programmers find bugs in |
76 | their programs, things that cannot happen unless there was a coding mistake. | |
fea681da MK |
77 | However, with system or library calls the situation is rather different, |
78 | and error returns can happen, and will happen, and should be tested for. | |
2f0af33b MK |
79 | Not by an assert, where the test goes away when |
80 | .B NDEBUG | |
81 | is defined, | |
c13182ef MK |
82 | but by proper error handling code. |
83 | Never use this macro. | |
47297adb | 84 | .SH SEE ALSO |
fea681da MK |
85 | .BR abort (3), |
86 | .BR assert (3), | |
87 | .BR exit (3), | |
0a4f8b7b | 88 | .BR strerror (3) |