Debian Codegraph @

upstream/debian-trixie/man3/assert_perror.3

raw
1 '\" t
2 .\" Copyright (C) 2002 Andries Brouwer <[email protected]>
3 .\"
4 .\" SPDX-License-Identifier: Linux-man-pages-copyleft
5 .\"
6 .\" This replaces an earlier man page written by Walter Harms
7 .\" <[email protected]>.
8 .\"
9 .TH assert_perror 3 2024-05-02 "Linux man-pages 6.9.1"
10 .SH NAME
11 assert_perror \- test errnum and abort
12 .SH LIBRARY
13 Standard C library
14 .RI ( libc ", " \-lc )
15 .SH SYNOPSIS
16 .nf
17 .BR "#define _GNU_SOURCE" " /* See feature_test_macros(7) */"
18 .B #include <assert.h>
19 .P
20 .BI "void assert_perror(int " errnum );
21 .fi
22 .SH DESCRIPTION
23 If the macro
24 .B NDEBUG
25 was defined at the moment
26 .I <assert.h>
27 was last included, the macro
28 .BR assert_perror ()
29 generates no code, and hence does nothing at all.
30 Otherwise, the macro
31 .BR assert_perror ()
32 prints an error message to standard error and terminates the program
33 by calling
34 .BR abort (3)
35 if
36 .I errnum
37 is nonzero.
38 The message contains the filename, function name and
39 line number of the macro call, and the output of
40 .IR strerror(errnum) .
41 .SH RETURN VALUE
42 No value is returned.
43 .SH ATTRIBUTES
44 For an explanation of the terms used in this section, see
45 .BR attributes (7).
46 .TS
47 allbox;
48 lbx lb lb
49 l l l.
50 Interface Attribute Value
51 T{
52 .na
53 .nh
54 .BR assert_perror ()
55 T} Thread safety MT-Safe
56 .TE
57 .SH STANDARDS
58 GNU.
59 .SH BUGS
60 The purpose of the assert macros is to help programmers find bugs in
61 their programs, 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.
64 Not by an assert, where the test goes away when
65 .B NDEBUG
66 is defined,
67 but by proper error handling code.
68 Never use this macro.
69 .SH SEE ALSO
70 .BR abort (3),
71 .BR assert (3),
72 .BR exit (3),
73 .BR strerror (3)