]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man3/assert_perror.3
ttyslot.3: tfix
[thirdparty/man-pages.git] / man3 / assert_perror.3
CommitLineData
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
30assert_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
39If the macro
40.B NDEBUG
41was defined at the moment
bd12ab88 42.I <assert.h>
fea681da 43was last included, the macro
63aa9df0 44.BR assert_perror ()
fea681da
MK
45generates no code, and hence does nothing at all.
46Otherwise, the macro
63aa9df0 47.BR assert_perror ()
7bbdabc4 48prints an error message to standard error and terminates the program
fea681da 49by calling
fb186734 50.BR abort (3)
fea681da
MK
51if
52.I errnum
c7094399 53is nonzero.
c13182ef 54The message contains the filename, function name and
fea681da
MK
55line number of the macro call, and the output of
56.IR strerror(errnum) .
47297adb 57.SH RETURN VALUE
fea681da 58No value is returned.
24d428e4
MS
59.SH ATTRIBUTES
60For an explanation of the terms used in this section, see
61.BR attributes (7).
62.TS
63allbox;
64lb lb lb
65l l l.
66Interface Attribute Value
67T{
68.BR assert_perror ()
69T} Thread safety MT-Safe
70.TE
847e0d88 71.sp 1
47297adb 72.SH CONFORMING TO
fea681da
MK
73This is a GNU extension.
74.SH BUGS
886ea57d
MK
75The purpose of the assert macros is to help programmers find bugs in
76their programs, things that cannot happen unless there was a coding mistake.
fea681da
MK
77However, with system or library calls the situation is rather different,
78and error returns can happen, and will happen, and should be tested for.
2f0af33b
MK
79Not by an assert, where the test goes away when
80.B NDEBUG
81is defined,
c13182ef
MK
82but by proper error handling code.
83Never 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)