]>
Commit | Line | Data |
---|---|---|
fea681da MK |
1 | .\" Copyright (C) 2002 Andries Brouwer <aeb@cwi.nl> |
2 | .\" | |
5fbde956 | 3 | .\" SPDX-License-Identifier: Linux-man-pages-copyleft |
fea681da MK |
4 | .\" |
5 | .\" This replaces an earlier man page written by Walter Harms | |
6 | .\" <walter.harms@informatik.uni-oldenburg.de>. | |
7 | .\" | |
45186a5d | 8 | .TH ASSERT_PERROR 3 2021-03-22 "Linux man-pages (unreleased)" |
fea681da MK |
9 | .SH NAME |
10 | assert_perror \- test errnum and abort | |
b813014f AC |
11 | .SH LIBRARY |
12 | Standard C library | |
13 | .RI ( libc ", " \-lc ) | |
fea681da MK |
14 | .SH SYNOPSIS |
15 | .nf | |
b80f966b | 16 | .BR "#define _GNU_SOURCE" " /* See feature_test_macros(7) */" |
fea681da | 17 | .B #include <assert.h> |
68e4db0a | 18 | .PP |
fea681da MK |
19 | .BI "void assert_perror(int " errnum ); |
20 | .fi | |
21 | .SH DESCRIPTION | |
22 | If the macro | |
23 | .B NDEBUG | |
24 | was defined at the moment | |
bd12ab88 | 25 | .I <assert.h> |
fea681da | 26 | was last included, the macro |
63aa9df0 | 27 | .BR assert_perror () |
fea681da MK |
28 | generates no code, and hence does nothing at all. |
29 | Otherwise, the macro | |
63aa9df0 | 30 | .BR assert_perror () |
7bbdabc4 | 31 | prints an error message to standard error and terminates the program |
fea681da | 32 | by calling |
fb186734 | 33 | .BR abort (3) |
fea681da MK |
34 | if |
35 | .I errnum | |
c7094399 | 36 | is nonzero. |
c13182ef | 37 | The message contains the filename, function name and |
fea681da MK |
38 | line number of the macro call, and the output of |
39 | .IR strerror(errnum) . | |
47297adb | 40 | .SH RETURN VALUE |
fea681da | 41 | No value is returned. |
24d428e4 MS |
42 | .SH ATTRIBUTES |
43 | For an explanation of the terms used in this section, see | |
44 | .BR attributes (7). | |
c466875e MK |
45 | .ad l |
46 | .nh | |
24d428e4 MS |
47 | .TS |
48 | allbox; | |
c466875e | 49 | lbx lb lb |
24d428e4 MS |
50 | l l l. |
51 | Interface Attribute Value | |
52 | T{ | |
53 | .BR assert_perror () | |
54 | T} Thread safety MT-Safe | |
55 | .TE | |
c466875e MK |
56 | .hy |
57 | .ad | |
847e0d88 | 58 | .sp 1 |
3113c7f3 | 59 | .SH STANDARDS |
fea681da MK |
60 | This is a GNU extension. |
61 | .SH BUGS | |
886ea57d MK |
62 | The purpose of the assert macros is to help programmers find bugs in |
63 | their programs, things that cannot happen unless there was a coding mistake. | |
fea681da MK |
64 | However, with system or library calls the situation is rather different, |
65 | and error returns can happen, and will happen, and should be tested for. | |
2f0af33b MK |
66 | Not by an assert, where the test goes away when |
67 | .B NDEBUG | |
68 | is defined, | |
c13182ef MK |
69 | but by proper error handling code. |
70 | Never use this macro. | |
47297adb | 71 | .SH SEE ALSO |
fea681da MK |
72 | .BR abort (3), |
73 | .BR assert (3), | |
74 | .BR exit (3), | |
0a4f8b7b | 75 | .BR strerror (3) |